View previous topic :: View next topic |
Author |
Message |
nagn
Joined: 27 Nov 2012 Posts: 2
|
Posted: Tue Nov 27, 2012 1:39 am Post subject: Have issues linking the libminiupnpc library statically |
|
|
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 |
|
|
nagn
Joined: 27 Nov 2012 Posts: 2
|
Posted: Tue Nov 27, 2012 1:53 am Post subject: I found a solution |
|
|
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 |
|
|
miniupnp Site Admin
Joined: 14 Apr 2007 Posts: 1592
|
Posted: Sun Dec 02, 2012 2:12 pm Post subject: |
|
|
Makefile.mingw includes :
Code: |
LDLIBS = -lws2_32 -liphlpapi
|
_________________ Main miniUPnP author.
https://miniupnp.tuxfamily.org/ |
|
Back to top |
|
|
|