从源代码编译miniupnpc

时间:2013-11-03 11:33:58

标签: gcc dll compilation compiler-errors

我正在尝试从源代码(http://miniupnp.free.fr/files/download.php?file=miniupnpc-1.8.tar.gz)编译miniupnpc,我遇到了一些错误。我安装了MinGW并将其添加到路径中。然后我提取源并运行mingw32make.bat,我无法弄清楚出了什么问题。以下是命令

的输出
C:\Users\dev\tools\mingw\msys\1.0\home\Aidan\miniupnpc-1.8>>mingw32make.bat
mkdir dll
echo init > init
gcc -Wall -Os -DNDEBUG -D_WIN32_WINNT=0X501 -DSTATICLIB -c -o upnpc.o upnpc.c
gcc -Wall -Os -DNDEBUG -D_WIN32_WINNT=0X501 -c -o dll/upnpc.o upnpc.c
gcc -Wall -Os -DNDEBUG -D_WIN32_WINNT=0X501 -DSTATICLIB -c -o wingenminiupnpcstrings.o wingenminiupnpcstrings.c
gcc -Wall -Os -DNDEBUG -D_WIN32_WINNT=0X501 -DMINIUPNP_EXPORTS -c -o dll/wingenminiupnpcstrings.o wingenminiupnpcstrings.c
gcc   wingenminiupnpcstrings.o  -lws2_32 -liphlpapi -o wingenminiupnpcstrings
wingenminiupnpcstrings miniupnpcstrings.h.in miniupnpcstrings.h
Windows 6.1 Build 7601 Service Pack 1
MiniUPnPc version 1.8
15 lines written to miniupnpcstrings.h.
gcc -Wall -Os -DNDEBUG -D_WIN32_WINNT=0X501 -DSTATICLIB -c -o miniwget.o miniwget.c
gcc -Wall -Os -DNDEBUG -D_WIN32_WINNT=0X501 -DMINIUPNP_EXPORTS -c -o dll/miniwget.o miniwget.c
gcc -Wall -Os -DNDEBUG -D_WIN32_WINNT=0X501 -DSTATICLIB -c -o minixml.o minixml.c
gcc -Wall -Os -DNDEBUG -D_WIN32_WINNT=0X501 -DMINIUPNP_EXPORTS -c -o dll/minixml.o minixml.c
gcc -Wall -Os -DNDEBUG -D_WIN32_WINNT=0X501 -DSTATICLIB -c -o igd_desc_parse.o igd_desc_parse.c
gcc -Wall -Os -DNDEBUG -D_WIN32_WINNT=0X501 -DMINIUPNP_EXPORTS -c -o dll/igd_desc_parse.o igd_desc_parse.c
gcc -Wall -Os -DNDEBUG -D_WIN32_WINNT=0X501 -DSTATICLIB -c -o minisoap.o minisoap.c
gcc -Wall -Os -DNDEBUG -D_WIN32_WINNT=0X501 -DMINIUPNP_EXPORTS -c -o dll/minisoap.o minisoap.c
gcc -Wall -Os -DNDEBUG -D_WIN32_WINNT=0X501 -DSTATICLIB -c -o miniupnpc.o miniupnpc.c
miniupnpc.c: In function 'upnpDiscover':
miniupnpc.c:422:9: warning: variable 'dwRetVal' set but not used [-Wunused-but-set-variable]
   DWORD dwRetVal = 0;
         ^
gcc -Wall -Os -DNDEBUG -D_WIN32_WINNT=0X501 -DMINIUPNP_EXPORTS -c -o dll/miniupnpc.o miniupnpc.c
miniupnpc.c: In function 'upnpDiscover':
miniupnpc.c:422:9: warning: variable 'dwRetVal' set but not used [-Wunused-but-set-variable]
   DWORD dwRetVal = 0;
         ^
gcc -Wall -Os -DNDEBUG -D_WIN32_WINNT=0X501 -DSTATICLIB -c -o upnpreplyparse.o upnpreplyparse.c
gcc -Wall -Os -DNDEBUG -D_WIN32_WINNT=0X501 -DMINIUPNP_EXPORTS -c -o dll/upnpreplyparse.o upnpreplyparse.c
gcc -Wall -Os -DNDEBUG -D_WIN32_WINNT=0X501 -DSTATICLIB -c -o upnpcommands.o upnpcommands.c
gcc -Wall -Os -DNDEBUG -D_WIN32_WINNT=0X501 -DMINIUPNP_EXPORTS -c -o dll/upnpcommands.o upnpcommands.c
gcc -Wall -Os -DNDEBUG -D_WIN32_WINNT=0X501 -DSTATICLIB -c -o upnperrors.o upnperrors.c
gcc -Wall -Os -DNDEBUG -D_WIN32_WINNT=0X501 -DMINIUPNP_EXPORTS -c -o dll/upnperrors.o upnperrors.c
gcc -Wall -Os -DNDEBUG -D_WIN32_WINNT=0X501 -DSTATICLIB -c -o connecthostport.o connecthostport.c
gcc -Wall -Os -DNDEBUG -D_WIN32_WINNT=0X501 -DMINIUPNP_EXPORTS -c -o dll/connecthostport.o connecthostport.c
gcc -Wall -Os -DNDEBUG -D_WIN32_WINNT=0X501 -DSTATICLIB -c -o portlistingparse.o portlistingparse.c
gcc -Wall -Os -DNDEBUG -D_WIN32_WINNT=0X501 -DMINIUPNP_EXPORTS -c -o dll/portlistingparse.o portlistingparse.c
gcc -Wall -Os -DNDEBUG -D_WIN32_WINNT=0X501 -DSTATICLIB -c -o receivedata.o receivedata.c
gcc -Wall -Os -DNDEBUG -D_WIN32_WINNT=0X501 -DMINIUPNP_EXPORTS -c -o dll/receivedata.o receivedata.c
ar cr libminiupnpc.a miniwget.o minixml.o igd_desc_parse.o minisoap.o miniupnpc.o upnpreplyparse.o upnpcommands.o upnperrors.o connecthostport.o portlistingparse
.o receivedata.o
gcc -enable-stdcall-fixup -o upnpc-static upnpc.o libminiupnpc.a -lws2_32 -liphlpapi
c:/users/dev/tools/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: warning: cannot find entry symbol nable-stdcall-fixup; defaulting to
0000000000401000
dllwrap -k --driver-name gcc \
--def miniupnpc.def \
--output-def miniupnpc.dll.def \
--implib miniupnpc.lib -o miniupnpc.dll \
dll/miniwget.o dll/minixml.o dll/igd_desc_parse.o dll/minisoap.o dll/miniupnpc.o dll/upnpreplyparse.o dll/upnpcommands.o dll/upnperrors.o dll/connecthostport.o d
ll/portlistingparse.o dll/receivedata.o -lws2_32 -liphlpapi
dlltool: Syntax error in def file miniupnpc.def:5
dlltool: Syntax error in def file miniupnpc.def:5
echo miniupnpc.lib generated with miniupnpc.dll
miniupnpc.lib generated with miniupnpc.dll
gcc -enable-stdcall-fixup -o upnpc-shared dll/upnpc.o miniupnpc.lib -lws2_32 -liphlpapi
c:/users/dev/tools/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: warning: cannot find entry symbol nable-stdcall-fixup; defaulting to
0000000000401000
dll/upnpc.o:upnpc.c:(.text+0x31): undefined reference to `_imp__UPNP_GetConnectionTypeInfo'
dll/upnpc.o:upnpc.c:(.text+0x8f): undefined reference to `_imp__UPNP_GetStatusInfo'
dll/upnpc.o:upnpc.c:(.text+0x157): undefined reference to `_imp__UPNP_GetLinkLayerMaxBitRates'
dll/upnpc.o:upnpc.c:(.text+0x289): undefined reference to `_imp__UPNP_GetExternalIPAddress'
dll/upnpc.o:upnpc.c:(.text+0x3cd): undefined reference to `_imp__UPNP_GetExternalIPAddress'
dll/upnpc.o:upnpc.c:(.text+0x43b): undefined reference to `_imp__UPNP_AddPortMapping'
dll/upnpc.o:upnpc.c:(.text+0x44e): undefined reference to `_imp__strupnperror'
dll/upnpc.o:upnpc.c:(.text+0x4c2): undefined reference to `_imp__UPNP_GetSpecificPortMappingEntry'
dll/upnpc.o:upnpc.c:(.text+0x4d1): undefined reference to `_imp__strupnperror'
c:/users/dev/tools/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: dll/upnpc.o: bad reloc address 0x23 in section `.text.startup'
c:/users/dev/tools/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: final link failed: Invalid operation
collect2.exe: error: ld returned 1 exit status
Makefile.mingw:64: recipe for target 'upnpc-shared' failed
mingw32-make: *** [upnpc-shared] Error 1

1 个答案:

答案 0 :(得分:1)

  1. 选项-enable-stdcall-fixup需要以-Wl作为前缀,以便mingw32-g ++正确解析,因为-e...在解析时会被分割为-e ...。此前缀仅表示“不会将以下内容解析为-e nable-stdcall-fixup,而是-enable-stdcall-fixup
  2. warning: cannot find entry symbol nable-stdcall-fixup; defaulting