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 

Have issues linking the libminiupnpc library statically

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



Joined: 27 Nov 2012
Posts: 2

PostPosted: Tue Nov 27, 2012 1:39 am    Post subject: Have issues linking the libminiupnpc library statically Reply with quote

I have a basic console program in which I use winsock and libminiupnpc to map ports, but I cannot seem to properly link it as I get compiling errors.

Code:
 c:\mingw\bin\..\lib\gcc\i686-pc-mingw32\4.7.1\..\..\..\libminiupnpc.a(miniupnpc.o):miniupnpc.c|| undefined reference to `GetBestRoute@12'|

c:\mingw\bin\..\lib\gcc\i686-pc-mingw32\4.7.1\..\..\..\libminiupnpc.a(miniupnpc.o):miniupnpc.c|| undefined reference to `GetIpAddrTable@12'|

c:\mingw\bin\..\lib\gcc\i686-pc-mingw32\4.7.1\..\..\..\libminiupnpc.a(miniupnpc.o):miniupnpc.c|| undefined reference to `GetIpAddrTable@12'|


This is my full command that codeblocks executes

Code:
mingw32-g++.exe -Wall -DSTATICLIB  -g    -I..\..\..\..\MinGW\include\miniupnpc  -c "dllapi.cpp" -o obj\Debug\dllapi.o
mingw32-g++.exe  -o bin\Debug\faucetupnp.exe obj\Debug\dllapi.o   -lws2_32 -lminiupnpc  ..\..\..\..\MinGW\lib\libws2_32.a ..\..\..\..\MinGW\lib\libminiupnpc.a


faucetupnp.exe is my target console application and dllapi is my cpp file.

I am compiling using MinGW on Code Blocks. My operating system is Win 7 64bit edition. If there's any other information I should provide, I'd be glad to give it

Cheers,

nagn
Back to top
View user's profile Send private message
nagn



Joined: 27 Nov 2012
Posts: 2

PostPosted: Tue Nov 27, 2012 1:53 am    Post subject: I found a solution Reply with quote

This always happens, whenever I consult outside help I immediately find the issue.

Apparently I did not link the Iphlpapi library, and that's required. I just did a bunch of guess work and added -liphlpapi... and it worked!

If anyone's interested...

Code:
mingw32-g++.exe -Wall -DSTATICLIB  -g    -I..\..\..\..\MinGW\include\miniupnpc  -c "dllapi.cpp" -o obj\Debug\dllapi.o
mingw32-g++.exe  -o bin\Debug\faucetupnp.exe obj\Debug\dllapi.o   -lws2_32 -lminiupnpc -liphlpapi  ..\..\..\..\MinGW\lib\libws2_32.a ..\..\..\..\MinGW\lib\libminiupnpc.a
[/code]
Back to top
View user's profile Send private message
miniupnp
Site Admin


Joined: 14 Apr 2007
Posts: 1448

PostPosted: Sun Dec 02, 2012 2:12 pm    Post subject: Reply with quote

Makefile.mingw includes :
Code:

LDLIBS = -lws2_32 -liphlpapi

_________________
Main miniUPnP author.
http://miniupnp.tuxfamily.org/
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    miniupnp.tuxfamily.org Forum Index -> miniupnpd 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.