View previous topic :: View next topic |
Author |
Message |
robbiehanson
Joined: 28 Jun 2008 Posts: 3
|
Posted: Sat Jun 28, 2008 9:31 pm Post subject: Compiling in MinGW |
|
|
Miniupnp comes with a mingw makefile that works great for making the upnpc.exe. I would like to make a dll file to be used within my application. Does anybody know how to do this?
Here's where I've gotten so far. I installed MinGW and compiled all the sources:
Code: | gcc -c -Wall -Os -DNDEBUG -DWIN32 -DMINIUPNP_EXPORTS miniwget.c
gcc -c -Wall -Os -DNDEBUG -DWIN32 -DMINIUPNP_EXPORTS minixml.c
gcc -c -Wall -Os -DNDEBUG -DWIN32 -DMINIUPNP_EXPORTS igd_desc_parse.c
gcc -c -Wall -Os -DNDEBUG -DWIN32 -DMINIUPNP_EXPORTS minisoap.c
gcc -c -Wall -Os -DNDEBUG -DWIN32 -DMINIUPNP_EXPORTS miniupnpc.c
gcc -c -Wall -Os -DNDEBUG -DWIN32 -DMINIUPNP_EXPORTS upnpreplyparse.c
gcc -c -Wall -Os -DNDEBUG -DWIN32 -DMINIUPNP_EXPORTS upnpcommands.c
gcc -c -Wall -Os -DNDEBUG -DWIN32 -DMINIUPNP_EXPORTS upnperrors.c |
This works fine, and produces all the *.o files. Then, I created a definition file miniupnp.def (not entirely sure if this was needed, but all the other mingw makefiles I found had one...)
Code: |
LIBRARY
; mini upnp library
EXPORTS
; miniupnpc
freeUPNPDevlist
parserootdesc
UPNP_GetValidIGD
UPNP_GetIGDFromUrl
GetUPNPUrls
FreeUPNPUrls
; miniwget
miniwget
miniwget_getaddr
; upnpcommands
UPNP_GetTotalBytesSent
UPNP_GetTotalBytesReceived
UPNP_GetTotalPacketsSent
UPNP_GetTotalPacketsReceived
UPNP_GetStatusInfo
UPNP_GetConnectionTypeInfo
UPNP_GetExternalIPAddress
UPNP_GetLinkLayerMaxBitRates
UPNP_AddPortMapping
UPNP_DeletePortMapping
UPNP_GetPortMappingNumberOfEntries
UPNP_GetSpecificPortMappingEntry
UPNP_GetGenericPortMappingEntry
|
And finally, I tried to link it all together. (This is the part that didn't work)
Code: | dllwrap -k --driver-name gcc --def miniupnp.def --output-def miniupnp.dll.def --implib libminiupnp.a -o miniupnp.dll -lws2_32 miniwget.o minixml.o igd_desc_parse.o minisoap.o miniupnpc.o upnpreplyparse.o upnpcommands.o upnperrors.o |
Except I get the following error message:
Code: |
miniwget.o:miniwget.c:(.text+0x20): undefined reference to `gethostbyname@4'
miniwget.o:miniwget.c:(.text+0x56): undefined reference to `socket@12'
miniwget.o:miniwget.c:(.text+0x7b): undefined reference to `htons@4'
miniwget.o:miniwget.c:(.text+0x96): undefined reference to `connect@12'
miniwget.o:miniwget.c:(.text+0xaf): undefined reference to `closesocket@4'
miniwget.o:miniwget.c:(.text+0xdd): undefined reference to `getsockname@12'
miniwget.o:miniwget.c:(.text+0xeb): undefined reference to `inet_ntoa@4'
miniwget.o:miniwget.c:(.text+0x12c): undefined reference to `send@16'
miniwget.o:miniwget.c:(.text+0x283): undefined reference to `closesocket@4'
minisoap.o:minisoap.c:(.text+0xb6): undefined reference to `send@16'
minisoap.o:minisoap.c:(.text+0xc1): undefined reference to `WSAGetLastError@0'
miniupnpc.o:miniupnpc.c:(.text+0x2b3): undefined reference to `select@20'
miniupnpc.o:miniupnpc.c:(.text+0x2bc): undefined reference to `WSAGetLastError@0'
miniupnpc.o:miniupnpc.c:(.text+0x2e5): undefined reference to `recv@16'
miniupnpc.o:miniupnpc.c:(.text+0x2f0): undefined reference to `WSAGetLastError@0'
miniupnpc.o:miniupnpc.c:(.text+0x344): undefined reference to `socket@12'
miniupnpc.o:miniupnpc.c:(.text+0x353): undefined reference to `WSAGetLastError@0'
miniupnpc.o:miniupnpc.c:(.text+0x3a2): undefined reference to `htons@4'
miniupnpc.o:miniupnpc.c:(.text+0x3b3): undefined reference to `inet_addr@4'
miniupnpc.o:miniupnpc.c:(.text+0x3d4): undefined reference to `setsockopt@20'
miniupnpc.o:miniupnpc.c:(.text+0x3dd): undefined reference to `WSAGetLastError@0'
miniupnpc.o:miniupnpc.c:(.text+0x3fc): undefined reference to `inet_addr@4'
miniupnpc.o:miniupnpc.c:(.text+0x420): undefined reference to `setsockopt@20'
miniupnpc.o:miniupnpc.c:(.text+0x429): undefined reference to `WSAGetLastError@0'
miniupnpc.o:miniupnpc.c:(.text+0x450): undefined reference to `bind@12'
miniupnpc.o:miniupnpc.c:(.text+0x463): undefined reference to `WSAGetLastError@0'
miniupnpc.o:miniupnpc.c:(.text+0x47e): undefined reference to `closesocket@4'
miniupnpc.o:miniupnpc.c:(.text+0x48a): undefined reference to `WSAGetLastError@0'
miniupnpc.o:miniupnpc.c:(.text+0x4f5): undefined reference to `sendto@24'
miniupnpc.o:miniupnpc.c:(.text+0x54d): undefined reference to `closesocket@4'
miniupnpc.o:miniupnpc.c:(.text+0x833): undefined reference to `socket@12'
miniupnpc.o:miniupnpc.c:(.text+0x83f): undefined reference to `WSAGetLastError@0'
miniupnpc.o:miniupnpc.c:(.text+0x864): undefined reference to `htons@4'
miniupnpc.o:miniupnpc.c:(.text+0x86e): undefined reference to `inet_addr@4'
miniupnpc.o:miniupnpc.c:(.text+0x87f): undefined reference to `connect@12'
miniupnpc.o:miniupnpc.c:(.text+0x888): undefined reference to `WSAGetLastError@0'
miniupnpc.o:miniupnpc.c:(.text+0x8a0): undefined reference to `closesocket@4'
miniupnpc.o:miniupnpc.c:(.text+0x8df): undefined reference to `closesocket@4'
miniupnpc.o:miniupnpc.c:(.text+0xa9d): undefined reference to `closesocket@4'
collect2: ld returned 1 exit status
dllwrap: gcc exited with status 1
|
Does anybody know how to fix this problem? Or how to make a miniupnp dll?
For reference, I'm typing this in on the windows command line.
I'd like to make a little library to make it easy to use miniupnp (and eventually nat-pmp) in C#. If I can get it working I'll release it to the public. |
|
Back to top |
|
|
robbiehanson
Joined: 28 Jun 2008 Posts: 3
|
Posted: Sun Jun 29, 2008 7:47 am Post subject: |
|
|
I figured it out. The "-lws2_32" part needs to go last. Like so:
Code: | dllwrap -k --driver-name gcc --def miniupnp.def --output-def miniupnp.dll.def --implib libminiupnp.a -o miniupnp.dll
miniwget.o minixml.o igd_desc_parse.o minisoap.o miniupnpc.o upnpreplyparse.o upnpcommands.o upnperrors.o -lws2_32 |
|
|
Back to top |
|
|
miniupnp Site Admin
Joined: 14 Apr 2007 Posts: 1589
|
Posted: Sun Jun 29, 2008 7:51 pm Post subject: |
|
|
robbiehanson wrote: | I figured it out. The "-lws2_32" part needs to go last. Like so:
Code: | dllwrap -k --driver-name gcc --def miniupnp.def --output-def miniupnp.dll.def --implib libminiupnp.a -o miniupnp.dll
miniwget.o minixml.o igd_desc_parse.o minisoap.o miniupnpc.o upnpreplyparse.o upnpcommands.o upnperrors.o -lws2_32 |
|
Thanks for the good job ! _________________ Main miniUPnP author.
https://miniupnp.tuxfamily.org/ |
|
Back to top |
|
|
thompsongregory41 Guest
|
Posted: Sat Mar 19, 2011 10:44 pm Post subject: |
|
|
thanks mate |
|
Back to top |
|
|
|