libcurl + openssl + zlib(すべてソースからビルド)を含むアプリケーションをビルドしようとしています。それは順序をリンクに問題があってはならないことを意味する、-lws2_32
は-lcrypto
後に置かれ、上記から分かるようにlibws2_32への未定義の参照( 'getnameinfo'、 'getaddrinfo'、...)
g++ -std=c++0x -DWINVER=0x0501 -DCURL_STATICLIB "-ID:\\PROJEKTY\\PC\\libcurl_openssl_zlib\\src\\lib" -O0 -g3 -Wall -c -fmessage-length=0 -o "src\\main.o" "..\\src\\main.cpp"
g++ "-LD:\\PROJEKTY\\PC\\libcurl_openssl_zlib\\src\\lib\\curl" "-LD:\\PROJEKTY\\PC\\libcurl_openssl_zlib\\src\\lib\\openssl" "-LD:\\PROJEKTY\\PC\\libcurl_openssl_zlib\\src\\lib\\zlib" -v -static-libgcc -static-libstdc++ -o libcurl_openssl_zlib.exe "src\\main.o" -lcurl -lcurldll -lssl -lcrypto -lz -lwldap32 -lws2_32
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=c:/mingw/bin/../libexec/gcc/mingw32/5.3.0/lto-wrapper.exe
Target: mingw32
Configured with: ../src/gcc-5.3.0/configure --build=x86_64-pc-linux-gnu --host=mingw32 --prefix=/mingw --disable-win32-registry --target=mingw32 --with-arch=i586 --enable-languages=c,c++,objc,obj-c++,fortran,ada --enable-static --enable-shared --enable-threads --with-dwarf2 --disable-sjlj-exceptions --enable-version-specific-runtime-libs --with-libintl-prefix=/mingw --enable-libstdcxx-debug --with-tune=generic --enable-libgomp --disable-libvtv --enable-nls : (reconfigured) ../src/gcc-5.3.0/configure --build=x86_64-pc-linux-gnu --host=mingw32 --prefix=/mingw --disable-win32-registry --target=mingw32 --with-arch=i586 --enable-languages=c,c++,objc,obj-c++,fortran,ada --enable-static --enable-shared --enable-threads --with-dwarf2 --disable-sjlj-exceptions --enable-version-specific-runtime-libs --with-libiconv-prefix=/mingw --with-libintl-prefix=/mingw --enable-libstdcxx-debug --with-tune=generic --enable-libgomp --disable-libvtv --enable-nls
Thread model: win32
gcc version 5.3.0 (GCC)
COMPILER_PATH=c:/mingw/bin/../libexec/gcc/mingw32/5.3.0/;c:/mingw/bin/../libexec/gcc/;c:/mingw/bin/../lib/gcc/mingw32/5.3.0/../../../../mingw32/bin/
LIBRARY_PATH=c:/mingw/bin/../lib/gcc/mingw32/5.3.0/;c:/mingw/bin/../lib/gcc/;c:/mingw/bin/../lib/gcc/mingw32/5.3.0/../../../../mingw32/lib/;c:/mingw/bin/../lib/gcc/mingw32/5.3.0/../../../
COLLECT_GCC_OPTIONS='-LD:\PROJEKTY\PC\libcurl_openssl_zlib\src\lib\curl' '-LD:\PROJEKTY\PC\libcurl_openssl_zlib\src\lib\openssl' '-LD:\PROJEKTY\PC\libcurl_openssl_zlib\src\lib\zlib' '-v' '-static-libgcc' '-o' 'libcurl_openssl_zlib.exe' '-mtune=generic' '-march=i586'
c:/mingw/bin/../libexec/gcc/mingw32/5.3.0/collect2.exe -plugin c:/mingw/bin/../libexec/gcc/mingw32/5.3.0/liblto_plugin-0.dll -plugin-opt=c:/mingw/bin/../libexec/gcc/mingw32/5.3.0/lto-wrapper.exe -plugin-opt=-fresolution=C:\Users\Jacek\AppData\Local\Temp\cchJKgec.res -plugin-opt=-pass-through=-lmingw32 -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_eh -plugin-opt=-pass-through=-lmoldname -plugin-opt=-pass-through=-lmingwex -plugin-opt=-pass-through=-lmsvcrt -plugin-opt=-pass-through=-ladvapi32 -plugin-opt=-pass-through=-lshell32 -plugin-opt=-pass-through=-luser32 -plugin-opt=-pass-through=-lkernel32 -plugin-opt=-pass-through=-lmingw32 -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_eh -plugin-opt=-pass-through=-lmoldname -plugin-opt=-pass-through=-lmingwex -plugin-opt=-pass-through=-lmsvcrt -Bdynamic -o libcurl_openssl_zlib.exe c:/mingw/bin/../lib/gcc/mingw32/5.3.0/../../../crt2.o c:/mingw/bin/../lib/gcc/mingw32/5.3.0/crtbegin.o -LD:\PROJEKTY\PC\libcurl_openssl_zlib\src\lib\curl -LD:\PROJEKTY\PC\libcurl_openssl_zlib\src\lib\openssl -LD:\PROJEKTY\PC\libcurl_openssl_zlib\src\lib\zlib -Lc:/mingw/bin/../lib/gcc/mingw32/5.3.0 -Lc:/mingw/bin/../lib/gcc -Lc:/mingw/bin/../lib/gcc/mingw32/5.3.0/../../../../mingw32/lib -Lc:/mingw/bin/../lib/gcc/mingw32/5.3.0/../../.. src\main.o -lcurl -lcurldll -lssl -lcrypto -lz -lwldap32 -lws2_32 -Bstatic -lstdc++ -Bdynamic -lmingw32 -lgcc -lgcc_eh -lmoldname -lmingwex -lmsvcrt -ladvapi32 -lshell32 -luser32 -lkernel32 -lmingw32 -lgcc -lgcc_eh -lmoldname -lmingwex -lmsvcrt c:/mingw/bin/../lib/gcc/mingw32/5.3.0/crtend.o
D:\PROJEKTY\PC\libcurl_openssl_zlib\src\lib\openssl/libcrypto.a(b_addr.o):b_addr.c:(.text+0xaa): undefined reference to `getnameinfo'
D:\PROJEKTY\PC\libcurl_openssl_zlib\src\lib\openssl/libcrypto.a(b_addr.o):b_addr.c:(.text+0xb48): undefined reference to `getaddrinfo'
D:\PROJEKTY\PC\libcurl_openssl_zlib\src\lib\openssl/libcrypto.a(b_addr.o):b_addr.c:(.text+0xca0): undefined reference to `getaddrinfo'
D:\PROJEKTY\PC\libcurl_openssl_zlib\src\lib\openssl/libcrypto.a(b_addr.o):b_addr.c:(.text+0x819): undefined reference to `freeaddrinfo'
D:\PROJEKTY\PC\libcurl_openssl_zlib\src\lib\openssl/libcrypto.a(init.o):init.c:(.text+0x212): undefined reference to `GetModuleHandleEx'
D:\PROJEKTY\PC\libcurl_openssl_zlib\src\lib\openssl/libcrypto.a(init.o):init.c:(.text+0x984): undefined reference to `GetModuleHandleEx'
collect2.exe: error: ld returned 1 exit status
:それは私に、次のリンクエラーが発生します。 「ちょうどその時」、私は012Wのエラーにどのようにリンクしているのか分かりませんが、暗黙の宣言についてのエラーや警告をスローしてしまいますが、私は-DWINVER=0x0501
の結果をsimiarスレッドで提案しました。コンパイル)。
リンカーに冗長フラグを付けてライブラリの検索パスを確認したところ、正しいものです。 libws2_32.aが配置されている場所に行くと、それにnm
を実行すると、次の値を返します。
MSYS /c/MinGW/lib
$ nm.exe -g libws2_32.a | grep getnameinfo
00000000 I [email protected]
00000000 T [email protected]
問題の機能があるように見えるいます。
私には何が欠けていますか?
これは実際問題でした。なんらかの理由で、OpenSSLの "Configure mingw [...]"は、 'freeaddrinfo'、' getaddrinfo'および 'getnameinfo'を定義する' ws2tcpip.h'でチェックされる 'WINVER = XXX'のような定義を追加しません'もし' _WIN32_WINNT> = 0x0501'ならば。したがって 'perl Configure mingw [...]'を実行した後、MakefileのCFLAGSに '-DWINVER = 0x0501 -D_WIN32_WINNT = 0x0501'を追加して、それらの関数が定義されていることを確認しました。この変更でOpenSSLを再構築することで問題が解決されました。 –