我正在尝试从源代码(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
最佳答案
-enable-stdcall-fixup
必须以-Wl
为前缀,因为解析时-e...
将被拆分为-e ...
。该前缀只是意味着“不将以下内容解析为-e nable-stdcall-fixup
,而是解析为-enable-stdcall-fixup
” warning: cannot find entry symbol nable-stdcall-fixup; defaulting
关于gcc - 从源代码编译miniupnpc,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/19752479/