[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lwip-users] pylwIP - problems compiling on ubuntu 10.04

From: Amir Shalem
Subject: Re: [lwip-users] pylwIP - problems compiling on ubuntu 10.04
Date: Tue, 18 Oct 2011 17:11:57 +0200

On Tue, Oct 18, 2011 at 1:09 PM, Simon Goldschmidt <address@hidden> wrote:

Amir Shalem <address@hidden> wrote:
> on linux / Ubuntu 10.04 I still have some problems, which I'm not sure
> what
> is the solution:
> 1. struct timeval
> [..]
> But maybe this should go in unix/arch/sys_arch.h instead?

Yes, I think that would be better than adding it in every lwipopts.h (like it is now).

Can you push this fix in lwip-contrib.git, /ports/unix/include/cc.h?

> 2. h_errno in api/netdb.c
> If I don't change anything, and have LWIP_DNS_API_DECLARE_H_ERRNO defined
> the gcc compiler crashes!
> [..]
> I'm not sure what is the solution here...
> I'm guessing I will have the problem if I will enable sockets.h
> set_errno()
> as-well.

Doesn't it work if you just define LWIP_DNS_API_DECLARE_H_ERRNO to 0? If so, maybe that should go into the unix port as well?

No, because we need to have h_errno declared somewhere if we want to use it...
and we can't include linux's <netdb.h> because that will include the whole <sys/socket.h> which conflicts with lwip's headers.

In ubuntu 10.04, compiling a simple file crashes:
  # cat b.c
  int h_errno = 5;
  # gcc b.c -shared 
  collect2: ld terminated with signal 11 [Segmentation fault]

One solution I can think of, is using
        #define h_errno (lwip_h_errno)

to fix the linkage error, any thoughts about that?

> 4. (This is windows problem), I got re-definitions of errno macros
> [..]
> Because lwip.c code includes both <Python.h> & <lwip/sockets.h> they both
> attempt to define errno values.
> Please note that I can't #undef LWIP_PROVIDE_ERRNO, because Windows
> doesn't
> provide all macro values.

Hmm, I didn't have that problem with the win32 port, but I only included "windows.h", no winsock header files...

Maybe you can separate the python-related code from the lwip-related code and split them into separate C files? Another option would be to undef LWIP_PROVIDE_ERRNO and define the missing values in your cc.h file?

I have currently solved it by:

#include <pyconfig.h>
#include <Python.h>
#include "lwip/arch.h"

to force Python.h not to include later on <errno.h>
which fixes the compilation on Visual Studio, 
but then it breaks linux, because lwIP depends on linux's <errno.h> for defines, so I can either #include <lwip/sys.h> in my code
or you will add #include <errno.h> to unix's cc.h?

this way after you include <lwip/arch.h> you will get errno values defined,
of course don't forget remove #include <errno.h> from unix's arch/sys_arch.h as its not required any more - after its in arch/cc.h

Amir Shalem

reply via email to

[Prev in Thread] Current Thread [Next in Thread]