miniupnp.tuxfamily.org Forum Index miniupnp.tuxfamily.org
The forum about miniupnp and libnatpmp
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Can't compile on OS X 10.6.2
Goto page 1, 2  Next
 
Post new topic   Reply to topic    miniupnp.tuxfamily.org Forum Index -> miniupnpc Compilation/Installation
View previous topic :: View next topic  
Author Message
CTroxtell



Joined: 03 Jan 2010
Posts: 7

PostPosted: Sun Jan 03, 2010 6:42 pm    Post subject: Can't compile on OS X 10.6.2 Reply with quote

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
View user's profile Send private message
miniupnp
Site Admin


Joined: 14 Apr 2007
Posts: 1589

PostPosted: Sun Jan 03, 2010 11:23 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
CTroxtell



Joined: 03 Jan 2010
Posts: 7

PostPosted: Mon Jan 04, 2010 1:03 am    Post subject: Reply with quote

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
View user's profile Send private message
miniupnp
Site Admin


Joined: 14 Apr 2007
Posts: 1589

PostPosted: Mon Jan 04, 2010 7:46 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
CTroxtell



Joined: 03 Jan 2010
Posts: 7

PostPosted: Tue Jan 05, 2010 5:03 am    Post subject: Reply with quote

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
View user's profile Send private message
miniupnp
Site Admin


Joined: 14 Apr 2007
Posts: 1589

PostPosted: Tue Jan 05, 2010 10:56 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
CTroxtell



Joined: 03 Jan 2010
Posts: 7

PostPosted: Tue Jan 05, 2010 4:38 pm    Post subject: Reply with quote

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
View user's profile Send private message
miniupnp
Site Admin


Joined: 14 Apr 2007
Posts: 1589

PostPosted: Tue Jan 05, 2010 5:33 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
miniupnp
Site Admin


Joined: 14 Apr 2007
Posts: 1589

PostPosted: Tue Jan 05, 2010 5:44 pm    Post subject: Reply with quote

There is info here : http://developer.apple.com/Mac/library/documentation/Darwin/Reference/ManPages/man5/compat.5.html.
I guess the default of your SDK is having non Posix extension disabled.
Setting _DARWIN_C_SOURCE should turn them on.
_________________
Main miniUPnP author.
https://miniupnp.tuxfamily.org/
Back to top
View user's profile Send private message Visit poster's website
CTroxtell



Joined: 03 Jan 2010
Posts: 7

PostPosted: Tue Jan 05, 2010 9:06 pm    Post subject: Reply with quote

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
View user's profile Send private message
miniupnp
Site Admin


Joined: 14 Apr 2007
Posts: 1589

PostPosted: Wed Jan 06, 2010 9:37 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
CTroxtell



Joined: 03 Jan 2010
Posts: 7

PostPosted: Wed Jan 06, 2010 11:36 pm    Post subject: Reply with quote

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
View user's profile Send private message
miniupnp
Site Admin


Joined: 14 Apr 2007
Posts: 1589

PostPosted: Thu Jan 07, 2010 11:01 am    Post subject: Reply with quote

it looks like !
_________________
Main miniUPnP author.
https://miniupnp.tuxfamily.org/
Back to top
View user's profile Send private message Visit poster's website
CTroxtell



Joined: 03 Jan 2010
Posts: 7

PostPosted: Fri Jan 08, 2010 9:47 pm    Post subject: Reply with quote

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
View user's profile Send private message
csilv



Joined: 09 Jan 2010
Posts: 1

PostPosted: Sat Jan 09, 2010 10:54 pm    Post subject: a permanent fix Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    miniupnp.tuxfamily.org Forum Index -> miniupnpc Compilation/Installation All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP
© 2007 Thomas Bernard, author of MiniUPNP.