View previous topic :: View next topic |
Author |
Message |
CTroxtell
Joined: 03 Jan 2010 Posts: 7
|
Posted: Sun Jan 03, 2010 6:42 pm Post subject: Can't compile on OS X 10.6.2 |
|
|
I get this when I try to compile it on Snow Leopard. Can anyone help me out.
bash-3.2# make
cc -fPIC -O -Wall -DNDEBUG -DMINIUPNPC_SET_SOCKET_TIMEOUT -c -o minixmlvalid.o minixmlvalid.c
cc -fPIC -O -Wall -DNDEBUG -DMINIUPNPC_SET_SOCKET_TIMEOUT -c -o minixml.o minixml.c
cc minixmlvalid.o minixml.o -o minixmlvalid
minixml validation test
./minixmlvalid
14 events
touch validateminixml
/bin/sh updateminiupnpcstrings.sh
Detected OS [Darwin] version [10.2.0]
setting OS_STRING macro value to Darwin/10.2.0 in miniupnpcstrings.h.
cc -fPIC -O -Wall -DNDEBUG -DMINIUPNPC_SET_SOCKET_TIMEOUT -c -o miniwget.o miniwget.c
cc -fPIC -O -Wall -DNDEBUG -DMINIUPNPC_SET_SOCKET_TIMEOUT -c -o igd_desc_parse.o igd_desc_parse.c
cc -fPIC -O -Wall -DNDEBUG -DMINIUPNPC_SET_SOCKET_TIMEOUT -c -o minisoap.o minisoap.c
cc -fPIC -O -Wall -DNDEBUG -DMINIUPNPC_SET_SOCKET_TIMEOUT -c -o miniupnpc.o miniupnpc.c
miniupnpc.c: In function ‘upnpDiscover’:
miniupnpc.c:486: error: ‘IP_MULTICAST_IF’ undeclared (first use in this function)
miniupnpc.c:486: error: (Each undeclared identifier is reported only once
miniupnpc.c:486: error: for each function it appears in.)
make: *** [miniupnpc.o] Error 1 |
|
Back to top |
|
|
miniupnp Site Admin
Joined: 14 Apr 2007 Posts: 1589
|
Posted: Sun Jan 03, 2010 11:23 pm Post subject: |
|
|
I dont understand why it doesnt work.
According to this page http://osxfaq.com/man/4/ip.ws OS X supports the option.
And both <sys/socket.h> and <netinet/in.h> are included in miniupnpc.c. _________________ Main miniUPnP author.
https://miniupnp.tuxfamily.org/ |
|
Back to top |
|
|
CTroxtell
Joined: 03 Jan 2010 Posts: 7
|
Posted: Mon Jan 04, 2010 1:03 am Post subject: |
|
|
Just tried to make it again and got this. A little different then the first one
bash-3.2# make
cc -fPIC -O -Wall -DNDEBUG -DMINIUPNPC_SET_SOCKET_TIMEOUT -c -o miniupnpc.o miniupnpc.c
miniupnpc.c: In function ‘upnpDiscover’:
miniupnpc.c:486: error: ‘IP_MULTICAST_IF’ undeclared (first use in this function)
miniupnpc.c:486: error: (Each undeclared identifier is reported only once
miniupnpc.c:486: error: for each function it appears in.)
make: *** [miniupnpc.o] Error 1 |
|
Back to top |
|
|
miniupnp Site Admin
Joined: 14 Apr 2007 Posts: 1589
|
Posted: Mon Jan 04, 2010 7:46 am Post subject: |
|
|
it's the same error...
maybe there is some macro to set ton enable ‘IP_MULTICAST_IF’ in netinet/in.h ? _________________ Main miniUPnP author.
https://miniupnp.tuxfamily.org/ |
|
Back to top |
|
|
CTroxtell
Joined: 03 Jan 2010 Posts: 7
|
Posted: Tue Jan 05, 2010 5:03 am Post subject: |
|
|
miniupnp wrote: | it's the same error...
maybe there is some macro to set ton enable ‘IP_MULTICAST_IF’ in netinet/in.h ? |
A macro? Don't really know alot about that. Any help would be appreciated or if you know of anyone that might know thanks in advance. |
|
Back to top |
|
|
miniupnp Site Admin
Joined: 14 Apr 2007 Posts: 1589
|
Posted: Tue Jan 05, 2010 10:56 am Post subject: |
|
|
please send me the file /usr/include/netinet/in.h by email, I'll have a look. _________________ Main miniUPnP author.
https://miniupnp.tuxfamily.org/ |
|
Back to top |
|
|
CTroxtell
Joined: 03 Jan 2010 Posts: 7
|
Posted: Tue Jan 05, 2010 4:38 pm Post subject: |
|
|
E-mail sent, not sure if file location makes a difference or not but it was under System>Library>Frameworks>Kernel.framework>Versions>A>Headers>netinet |
|
Back to top |
|
|
miniupnp Site Admin
Joined: 14 Apr 2007 Posts: 1589
|
Posted: Tue Jan 05, 2010 5:33 pm Post subject: |
|
|
try to add Code: | #define _DARWIN_C_SOURCE | at the top of the miniupnpc.c file to see if it works better _________________ Main miniUPnP author.
https://miniupnp.tuxfamily.org/ |
|
Back to top |
|
|
miniupnp Site Admin
Joined: 14 Apr 2007 Posts: 1589
|
|
Back to top |
|
|
CTroxtell
Joined: 03 Jan 2010 Posts: 7
|
Posted: Tue Jan 05, 2010 9:06 pm Post subject: |
|
|
Okay I got a little progress I think. If I add #define _POSIX_C_SOURCE then I get this:
bash-3.2# make
cc -fPIC -O -Wall -DNDEBUG -DMINIUPNPC_SET_SOCKET_TIMEOUT -c -o miniwget.o miniwget.c
miniwget.c: In function ‘miniwget2’:
miniwget.c:61: warning: implicit declaration of function ‘herror’
miniwget.c:65: error: ‘struct hostent’ has no member named ‘h_addr’
miniwget.c:65: error: ‘struct hostent’ has no member named ‘h_addr’
make: *** [miniwget.o] Error 1
Adding #define _DARWIN_C_SOURCE and #define _POSIX_C_SOURCE I get
bash-3.2# make
cc -fPIC -O -Wall -DNDEBUG -DMINIUPNPC_SET_SOCKET_TIMEOUT -c -o miniwget.o miniwget.c
cc -fPIC -O -Wall -DNDEBUG -DMINIUPNPC_SET_SOCKET_TIMEOUT -c -o miniupnpc.o miniupnpc.c
In file included from miniupnpc.c:53:
miniupnpc.h:10:1: warning: "_POSIX_C_SOURCE" redefined
In file included from /usr/include/sys/_types.h:32,
from /usr/include/_types.h:27,
from /usr/include/stdlib.h:63,
from miniupnpc.c:19:
/usr/include/sys/cdefs.h:453:1: warning: this is the location of the previous definition
miniupnpc.c: In function ‘upnpDiscover’:
miniupnpc.c:486: error: ‘IP_MULTICAST_IF’ undeclared (first use in this function)
miniupnpc.c:486: error: (Each undeclared identifier is reported only once
miniupnpc.c:486: error: for each function it appears in.)
make: *** [miniupnpc.o] Error 1
Then if I have only #define _DARWIN_C_SOURCE I get this.
bash-3.2# make
cc -fPIC -O -Wall -DNDEBUG -DMINIUPNPC_SET_SOCKET_TIMEOUT -c -o miniwget.o miniwget.c
cc -fPIC -O -Wall -DNDEBUG -DMINIUPNPC_SET_SOCKET_TIMEOUT -c -o miniupnpc.o miniupnpc.c
miniupnpc.c: In function ‘upnpDiscover’:
miniupnpc.c:486: error: ‘IP_MULTICAST_IF’ undeclared (first use in this function)
miniupnpc.c:486: error: (Each undeclared identifier is reported only once
miniupnpc.c:486: error: for each function it appears in.)
make: *** [miniupnpc.o] Error 1
So the IP_MULTICAST_IF error goes away when I use the #define _POSIX_C_SOURCE but I get the other error. |
|
Back to top |
|
|
miniupnp Site Admin
Joined: 14 Apr 2007 Posts: 1589
|
Posted: Wed Jan 06, 2010 9:37 am Post subject: |
|
|
You haven't understood me.
you must #define _DARWIN_C_SOURCE on top of the miniupnpc.c (not .h) file, before any #include.
Another alternative is to add -D_DARWIN_C_SOURCE to CFLAGS.
Don't mess with _POSIX_C_SOURCE which disable non posix extensions. Don't touch the miniupnpc.h file. _________________ Main miniUPnP author.
https://miniupnp.tuxfamily.org/ |
|
Back to top |
|
|
CTroxtell
Joined: 03 Jan 2010 Posts: 7
|
Posted: Wed Jan 06, 2010 11:36 pm Post subject: |
|
|
Okay, sorry about the misunderstanding. I added it and got this
bash-3.2# make
cc -fPIC -O -Wall -DNDEBUG -DMINIUPNPC_SET_SOCKET_TIMEOUT -c -o miniwget.o miniwget.c
cc -fPIC -O -Wall -DNDEBUG -DMINIUPNPC_SET_SOCKET_TIMEOUT -c -o miniupnpc.o miniupnpc.c
cc -fPIC -O -Wall -DNDEBUG -DMINIUPNPC_SET_SOCKET_TIMEOUT -c -o upnpreplyparse.o upnpreplyparse.c
cc -fPIC -O -Wall -DNDEBUG -DMINIUPNPC_SET_SOCKET_TIMEOUT -c -o upnpcommands.o upnpcommands.c
cc -fPIC -O -Wall -DNDEBUG -DMINIUPNPC_SET_SOCKET_TIMEOUT -c -o minissdpc.o minissdpc.c
cc -fPIC -O -Wall -DNDEBUG -DMINIUPNPC_SET_SOCKET_TIMEOUT -c -o upnperrors.o upnperrors.c
ar crs libminiupnpc.a miniwget.o minixml.o igd_desc_parse.o minisoap.o miniupnpc.o upnpreplyparse.o upnpcommands.o minissdpc.o upnperrors.o
cc -fPIC -O -Wall -DNDEBUG -DMINIUPNPC_SET_SOCKET_TIMEOUT -c -o upnpc.o upnpc.c
cc -o upnpc-static upnpc.o libminiupnpc.a
cc -dynamiclib -Wl,-install_name,libminiupnpc.4.dylib -o libminiupnpc.dylib miniwget.o minixml.o igd_desc_parse.o minisoap.o miniupnpc.o upnpreplyparse.o upnpcommands.o minissdpc.o upnperrors.o
cc -o upnpc-shared upnpc.o libminiupnpc.dylib
cc -fPIC -O -Wall -DNDEBUG -DMINIUPNPC_SET_SOCKET_TIMEOUT -c -o testminixml.o testminixml.c
cc testminixml.o minixml.o igd_desc_parse.o -o testminixml
cc -fPIC -O -Wall -DNDEBUG -DMINIUPNPC_SET_SOCKET_TIMEOUT -c -o testupnpreplyparse.o testupnpreplyparse.c
cc testupnpreplyparse.o minixml.o upnpreplyparse.o -o testupnpreplyparse
cc -fPIC -O -Wall -DNDEBUG -DMINIUPNPC_SET_SOCKET_TIMEOUT -c -o testigddescparse.o testigddescparse.c
cc testigddescparse.o igd_desc_parse.o minixml.o -o testigddescparse
Did it work? |
|
Back to top |
|
|
miniupnp Site Admin
Joined: 14 Apr 2007 Posts: 1589
|
|
Back to top |
|
|
CTroxtell
Joined: 03 Jan 2010 Posts: 7
|
Posted: Fri Jan 08, 2010 9:47 pm Post subject: |
|
|
Okay great, now where did it install at and how do I use it? I looked at the makefile and it says /usr/bin I think but as far as I know there is no such directory on OS X. |
|
Back to top |
|
|
csilv
Joined: 09 Jan 2010 Posts: 1
|
Posted: Sat Jan 09, 2010 10:54 pm Post subject: a permanent fix |
|
|
Hi Thomas,
The ideal fix for compiling on Mac (this also applies to old versions) is to change the following segment:
#ifdef MACOSX
#define _DARWIN_C_SOURCE
#endif
to:
#ifdef __APPLE__
#define _DARWIN_C_SOURCE
#endif
(You already use the __APPLE__ macro in libnatpmp (getgateway.c).
Hope this helps,
Chris |
|
Back to top |
|
|
|