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 

addrinfo linking problem with recent gcc versions

 
Post new topic   Reply to topic    miniupnp.tuxfamily.org Forum Index -> miniupnpc Compilation/Installation
View previous topic :: View next topic  
Author Message
Zartox



Joined: 27 Jun 2012
Posts: 6

PostPosted: Wed Jul 04, 2012 5:15 am    Post subject: addrinfo linking problem with recent gcc versions Reply with quote

On the project using miniupnpc I had (on Windows XP 32b and Win 8 32b):
Linking gserver2
Warning: resolving _getaddrinfo by linking to _getaddrinfo@16
Use --enable-stdcall-fixup to disable these warnings
Use --disable-stdcall-fixup to disable these fixups
Warning: resolving _getnameinfo by linking to _getnameinfo@28
obj/Debug/connecthostport.o: In function `connecthostport':
c:\graal_reborn\gserver-v2\trunk\build\projects/../../dependencies/miniupnpc/connecthostport.c:227: undefined reference to `freeaddrinfo'
obj/Debug/miniupnpc.o: In function `upnpDiscover':
c:\graal_reborn\gserver-v2\trunk\build\projects/../../dependencies miniupnpc/min
iupnpc.c:619: undefined reference to `freeaddrinfo'
collect2: ld returned 1 exit status
make[1]: *** [../../bin/gserver2_d.exe] Error 1
make: *** [gserver2] Error 2

I applied the alucard fix at:
http://miniupnp.tuxfamily.org/forum/viewtopic.php?t=642

Which is to add:
//Paul begin
TODO: make it for Windows XP too
#if (_WIN32_WINNT >= _WIN32_WINNT_WIN7)
void WSAAPI freeaddrinfo (struct addrinfo*);
int WSAAPI getaddrinfo (const char*,const char*,const struct addrinfo*,struct addrinfo**);
int WSAAPI getnameinfo(const struct sockaddr*,socklen_t,char*,DWORD,char*,DWORD,int);
#endif
//Paul End
in connecthosport.c and miniupnpc.c after the #include s.

Did not done the edit of ws2tcpip.h part.
But it seems to work fine.

For me (the guy who does not know much C because it consider it bad), it looks like a Win32 api bug in MinGW, that is in w32api-3.17-2-mingw32-dev.tar.lzma.
But I'll try to ask first on miniupnpc forum. (Eh... That's what I am doing)
Back to top
View user's profile Send private message
miniupnp
Site Admin


Joined: 14 Apr 2007
Posts: 1589

PostPosted: Wed Jul 04, 2012 9:04 am    Post subject: Reply with quote

indeed it looks like there is a problem with the mingw32 version you are using.
_________________
Main miniUPnP author.
https://miniupnp.tuxfamily.org/
Back to top
View user's profile Send private message Visit poster's website
Zartox



Joined: 27 Jun 2012
Posts: 6

PostPosted: Thu Jul 05, 2012 1:30 pm    Post subject: Workaround ws2tcpip.h 'bug' in MinGW Reply with quote

Edit3:
The problem seems that _WIN32_WINNT might not yet be defined in ws2tcpip.h when it comes to:
Code:
#if (_WIN32_WINNT >= 0x0501)
void WSAAPI freeaddrinfo (struct addrinfo*);
int WSAAPI getaddrinfo (const char*,const char*,const struct addrinfo*,
              struct addrinfo**);
int WSAAPI getnameinfo(const struct sockaddr*,socklen_t,char*,DWORD,
             char*,DWORD,int);
#else
/* FIXME: Need WS protocol-independent API helpers.  */
#endif


Edit2: Oh, I see now that _WIN32_WINNT is defined in windef.h:
Code:
#ifndef _WIN32_WINNT
#define _WIN32_WINNT WINVER
/*
 * There may be the need to define _WIN32_WINNT to a value different from
 * the value of WINVER.  I don't have any example of why you would do that.
 * However, if you must then define _WIN32_WINNT to the value required before
 * including windows.h or any other method of including the windef.h header.
 */
#endif

Is windef.h in VisualStudio too? Looks like adding:
#include <windef.h>
would be a more correct workaround to me.

Looks like it finally got reported May 18, on MinGW:
http://sourceforge.net/tracker/index.php?func=detail&aid=3527915&group_id=2435&atid=102435
Back to top
View user's profile Send private message
miniupnp
Site Admin


Joined: 14 Apr 2007
Posts: 1589

PostPosted: Thu Jul 05, 2012 2:36 pm    Post subject: Reply with quote

try to add -DWINVER=0x0501 to the CFLAGS
_________________
Main miniUPnP author.
https://miniupnp.tuxfamily.org/
Back to top
View user's profile Send private message Visit poster's website
Zartox



Joined: 27 Jun 2012
Posts: 6

PostPosted: Thu Jul 05, 2012 3:33 pm    Post subject: Reply with quote

miniupnp wrote:
try to add -DWINVER=0x0501 to the CFLAGS

I am not in front of my own computer.
But I don't see how defining WINVER would make _WIN32_WINNT defined.
I really believed the problem to be that ws2tcpip.h does not include windef.h.

That said, all the include files seems to have been erased (they are dead) in the MinGW HEAD. Still trying to figure out where they are gone:
http://mingw.cvs.sourceforge.net/viewvc/mingw/w32api/lib/?hideattic=0
Edit: Well, that would be 6 years that the files would have been erased
Edit: So I guess the files I browse are not up to date.


Even the dead file have not this code.

I am lost.
Back to top
View user's profile Send private message
miniupnp
Site Admin


Joined: 14 Apr 2007
Posts: 1589

PostPosted: Thu Jul 05, 2012 6:40 pm    Post subject: Reply with quote

Sorry, I meant -D_WIN32_WINNT=0X501
That is what is in Makefile.mingw
_________________
Main miniUPnP author.
https://miniupnp.tuxfamily.org/
Back to top
View user's profile Send private message Visit poster's website
Zartox



Joined: 27 Jun 2012
Posts: 6

PostPosted: Thu Jul 05, 2012 7:13 pm    Post subject: Reply with quote

miniupnp wrote:
try to add -DWINVER=0x0501 to the CFLAGS

I am not in front of my own computer.
But I don't see how defining WINVER would make _WIN32_WINNT defined.
I really believed the problem to be that ws2tcpip.h does not include windef.h.

Edit1 removed.
Edit2: You were rigfht! Adding -DWINVER=0x0501 to the CFLAGS did fix it!
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
Page 1 of 1

 
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.