在C ++中链接cURL

时间:2012-10-15 23:28:07

标签: c++ curl libcurl

今天在没有结果的情况下尝试了这一切,并在这里和论坛上搜索了很多线程,我希望有人能够找到解决方案。

我正在尝试使用MinGW让this simple example using cURL在Windows上运行。

当我尝试用g ++编译它时

g++ -o Test.exe Test.cpp -DCURL_STATICLIB -I curl\include -L curl\lib -lcurl

它总是给我同样的错误:

C:\Users\Xenon\AppData\Local\Temp\ccI5UUEq.o:Test.cpp:(.text+0x87): undefined reference to `_curl_easy_init'
C:\Users\Xenon\AppData\Local\Temp\ccI5UUEq.o:Test.cpp:(.text+0xb6): undefined reference to `_curl_easy_setopt'
C:\Users\Xenon\AppData\Local\Temp\ccI5UUEq.o:Test.cpp:(.text+0xc2): undefined reference to `_curl_easy_perform'
C:\Users\Xenon\AppData\Local\Temp\ccI5UUEq.o:Test.cpp:(.text+0xd9): undefined reference to `_curl_easy_strerror'
C:\Users\Xenon\AppData\Local\Temp\ccI5UUEq.o:Test.cpp:(.text+0x101): undefined reference to `_curl_easy_cleanup'
collect2.exe: error: ld returned 1 exit status

说实话,我完全没有想法可能导致这种情况。任何帮助将不胜感激。提前谢谢!

修改 添加参数-v时,我得到以下输出:

g++ -v -o Test.exe Test.cpp -DCURL_STATICLIB -I curl\include -L curl\lib -lcurl
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=c:/mingw/bin/../libexec/gcc/mingw32/4.7.0/lto-wrapper.exe
Target: mingw32
Configured with: ../gcc-4.7.0/configure --enable-languages=c,c++,ada,fortran,objc,obj-c++ --disable-sjlj-exceptions --with-dwarf2 --enable-shared --enable-libgomp --disable-win32-registry --enable-libstdcxx-debug --disable-build-poststage1-with-cxx --enable-version-specific-runtime-libs --build=mingw32 --prefix=/mingw
Thread model: win32
gcc version 4.7.0 (GCC)
COLLECT_GCC_OPTIONS='-v' '-o' 'Test.exe' '-D' 'CURL_STATICLIB' '-I' 'curl\include' '-Lcurl\lib' '-shared-libgcc' '-mtune=i386' '-march=i386'
 c:/mingw/bin/../libexec/gcc/mingw32/4.7.0/cc1plus.exe -quiet -v -I curl\include
 -iprefix c:\mingw\bin\../lib/gcc/mingw32/4.7.0/ -D CURL_STATICLIB Test.cpp -quiet -dumpbase Test.cpp -mtune=i386 -march=i386 -auxbase Test -version -o C:\Users\Xenon\AppData\Local\Temp\ccsSlqnP.s
GNU C++ (GCC) version 4.7.0 (mingw32)
        compiled by GNU C version 4.7.0, GMP version 5.0.1, MPFR version 2.4.1,
MPC version 0.8.1
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory "c:\mingw\bin\../lib/gcc/mingw32/4.7.0/../../../../mingw32/include"
ignoring duplicate directory "c:/mingw/lib/gcc/../../lib/gcc/mingw32/4.7.0/include/c++"
ignoring duplicate directory "c:/mingw/lib/gcc/../../lib/gcc/mingw32/4.7.0/include/c++/mingw32"
ignoring duplicate directory "c:/mingw/lib/gcc/../../lib/gcc/mingw32/4.7.0/include/c++/backward"
ignoring duplicate directory "c:/mingw/lib/gcc/../../lib/gcc/mingw32/4.7.0/include"
ignoring nonexistent directory "/mingw/include"
ignoring duplicate directory "c:/mingw/lib/gcc/../../include"
ignoring duplicate directory "c:/mingw/lib/gcc/../../lib/gcc/mingw32/4.7.0/include-fixed"
ignoring nonexistent directory "c:/mingw/lib/gcc/../../lib/gcc/mingw32/4.7.0/../../../../mingw32/include"
ignoring nonexistent directory "/mingw/include"
#include "..." search starts here:
#include <...> search starts here:
 curl\include
 c:\mingw\bin\../lib/gcc/mingw32/4.7.0/include/c++
 c:\mingw\bin\../lib/gcc/mingw32/4.7.0/include/c++/mingw32
 c:\mingw\bin\../lib/gcc/mingw32/4.7.0/include/c++/backward
 c:\mingw\bin\../lib/gcc/mingw32/4.7.0/include
 c:\mingw\bin\../lib/gcc/mingw32/4.7.0/../../../../include
 c:\mingw\bin\../lib/gcc/mingw32/4.7.0/include-fixed
End of search list.
GNU C++ (GCC) version 4.7.0 (mingw32)
        compiled by GNU C version 4.7.0, GMP version 5.0.1, MPFR version 2.4.1, MPC version 0.8.1
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 9fc40f37d31a03e5502141ce58bdf4c7
COLLECT_GCC_OPTIONS='-v' '-o' 'Test.exe' '-D' 'CURL_STATICLIB' '-I' 'curl\include' '-Lcurl\lib' '-shared-libgcc' '-mtune=i386' '-march=i386'
 c:/mingw/bin/../lib/gcc/mingw32/4.7.0/../../../../mingw32/bin/as.exe -o C:\Users\Xenon\AppData\Local\Temp\ccYxunOQ.o C:\Users\Xenon\AppData\Local\Temp\ccsSlqnP.s
COMPILER_PATH=c:/mingw/bin/../libexec/gcc/mingw32/4.7.0/;c:/mingw/bin/../libexec/gcc/;c:/mingw/bin/../lib/gcc/mingw32/4.7.0/../../../../mingw32/bin/
LIBRARY_PATH=c:/mingw/bin/../lib/gcc/mingw32/4.7.0/;c:/mingw/bin/../lib/gcc/;c:/mingw/bin/../lib/gcc/mingw32/4.7.0/../../../../mingw32/lib/;c:/mingw/bin/../lib/gcc/mingw32/4.7.0/../../../
COLLECT_GCC_OPTIONS='-v' '-o' 'Test.exe' '-D' 'CURL_STATICLIB' '-I' 'curl\include' '-Lcurl\lib' '-shared-libgcc' '-mtune=i386' '-march=i386'
 c:/mingw/bin/../libexec/gcc/mingw32/4.7.0/collect2.exe -Bdynamic -u ___register_frame_info -u ___deregister_frame_info -o Test.exe c:/mingw/bin/../lib/gcc/mingw32/4.7.0/../../../crt2.o c:/mingw/bin/../lib/gcc/mingw32/4.7.0/crtbegin.o -Lcurl\lib -Lc:/mingw/bin/../lib/gcc/mingw32/4.7.0 -Lc:/mingw/bin/../lib/gcc -Lc:/mingw/bin/../lib/gcc/mingw32/4.7.0/../../../../mingw32/lib -Lc:/mingw/bin/../lib/gcc/mingw32/4.7.0/../../.. C:\Users\Xenon\AppData\Local\Temp\ccYxunOQ.o -lcurl -lstdc++ -lmingw32 -lgcc_s -lgcc -lmoldname -lmingwex -lmsvcrt -ladvapi32 -lshell32
 -luser32 -lkernel32 -lmingw32 -lgcc_s -lgcc -lmoldname -lmingwex -lmsvcrt c:/mingw/bin/../lib/gcc/mingw32/4.7.0/crtend.o
C:\Users\Xenon\AppData\Local\Temp\ccYxunOQ.o:Test.cpp:(.text+0xf): undefined reference to `_curl_easy_init'
C:\Users\Xenon\AppData\Local\Temp\ccYxunOQ.o:Test.cpp:(.text+0x36): undefined reference to `_curl_easy_setopt'
C:\Users\Xenon\AppData\Local\Temp\ccYxunOQ.o:Test.cpp:(.text+0x42): undefined reference to `_curl_easy_perform'
C:\Users\Xenon\AppData\Local\Temp\ccYxunOQ.o:Test.cpp:(.text+0x59): undefined reference to `_curl_easy_strerror'
C:\Users\Xenon\AppData\Local\Temp\ccYxunOQ.o:Test.cpp:(.text+0x81): undefined reference to `_curl_easy_cleanup'
collect2.exe: error: ld returned 1 exit status

我仍然不知道可能导致我的问题的原因是......所有那些“被忽略”的目录都正常吗?

编辑:现在使用32位cURL库后,编译器就会发送错误消息。我不知道它是否意味着它正在工作或者现在更加破碎...不得不删除一些消息,因为它们是506行......

>g++ -o Test.exe Test.cpp -DCURL_STATICLIB -I curl\include -L curl\lib -lcurl
curl\lib/libcurl.a(easy.o):(.text+0x16): undefined reference to `_WSAStartup@8'
curl\lib/libcurl.a(easy.o):(.text+0x39): undefined reference to `_WSACleanup@0'
[...]
curl\lib/libcurl.a(ssluse.o):(.text+0x1662): undefined reference to `_BN_num_bits'
curl\lib/libcurl.a(ssluse.o):(.text+0x1688): undefined reference to `_BN_num_bits'
curl\lib/libcurl.a(ssluse.o):(.text+0x16cb): undefined reference to `_BN_num_bits'
curl\lib/libcurl.a(ssluse.o):(.text+0x16f7): undefined reference to `_BN_num_bits'
curl\lib/libcurl.a(ssluse.o):(.text+0x1723): undefined reference to `_BN_num_bits'
curl\lib/libcurl.a(ssluse.o):(.text+0x174f): more undefined references to `_BN_num_bits' follow
curl\lib/libcurl.a(ssluse.o):(.text+0x1833): undefined reference to `_BN_bn2bin'
curl\lib/libcurl.a(ssluse.o):(.text+0x1876): undefined reference to `_BN_num_bits'
curl\lib/libcurl.a(ssluse.o):(.text+0x18a2): undefined reference to `_BN_num_bits'
curl\lib/libcurl.a(ssluse.o):(.text+0x18ce): undefined reference to `_BN_num_bits'
curl\lib/libcurl.a(ssluse.o):(.text+0x18fa): undefined reference to `_BN_num_bits'
curl\lib/libcurl.a(ssluse.o):(.text+0x192a): undefined reference to `_BN_num_bits'
curl\lib/libcurl.a(ssluse.o):(.text+0x195a): undefined reference to `_BN_bn2bin'
curl\lib/libcurl.a(ssluse.o):(.text+0x199a): undefined reference to `_BN_num_bits'
curl\lib/libcurl.a(ssluse.o):(.text+0x19c6): undefined reference to `_BN_num_bits'
curl\lib/libcurl.a(ssluse.o):(.text+0x19f2): undefined reference to `_BN_num_bits'
curl\lib/libcurl.a(ssluse.o):(.text+0x1a22): undefined reference to `_BN_num_bits'
curl\lib/libcurl.a(ssluse.o):(.text+0x1a52): undefined reference to `_BN_bn2bin'
curl\lib/libcurl.a(ssluse.o):(.text+0x1ade): undefined reference to `_BN_bn2bin'
curl\lib/libcurl.a(ssluse.o):(.text+0x1b22): undefined reference to `_BN_bn2bin'
curl\lib/libcurl.a(ssluse.o):(.text+0x1b66): undefined reference to `_BN_bn2bin'
curl\lib/libcurl.a(ssluse.o):(.text+0x1baa): undefined reference to `_BN_bn2bin'
curl\lib/libcurl.a(ssluse.o):(.text+0x1bee): more undefined references to `_BN_bn2bin' follow
curl\lib/libcurl.a(ssluse.o):(.text+0x1e8c): undefined reference to `_GENERAL_NAMES_free'
curl\lib/libcurl.a(ssluse.o):(.text+0x1ea0): undefined reference to `_X509_get_subject_name'
curl\lib/libcurl.a(ssluse.o):(.text+0x1eca): undefined reference to `_X509_NAME_get_index_by_NID'
curl\lib/libcurl.a(ssluse.o):(.text+0x1ee2): undefined reference to `_X509_NAME_get_entry'
curl\lib/libcurl.a(ssluse.o):(.text+0x1eea): undefined reference to `_X509_NAME_ENTRY_get_data'
curl\lib/libcurl.a(ssluse.o):(.text+0x1efc): undefined reference to `_ASN1_STRING_type'
curl\lib/libcurl.a(ssluse.o):(.text+0x1f15): undefined reference to `_ASN1_STRING_to_UTF8'
curl\lib/libcurl.a(ssluse.o):(.text+0x1f7f): undefined reference to `_CRYPTO_free'
curl\lib/libcurl.a(ssluse.o):(.text+0x1f96): undefined reference to `_X509_free'
curl\lib/libcurl.a(ssluse.o):(.text+0x203f): undefined reference to `_ASN1_STRING_data'
curl\lib/libcurl.a(ssluse.o):(.text+0x2052): undefined reference to `_ASN1_STRING_length'
curl\lib/libcurl.a(ssluse.o):(.text+0x20e0): undefined reference to `_PEM_read_X509'
curl\lib/libcurl.a(ssluse.o):(.text+0x2105): undefined reference to `_X509_check_issued'
curl\lib/libcurl.a(ssluse.o):(.text+0x213e): undefined reference to `_X509_free'
curl\lib/libcurl.a(ssluse.o):(.text+0x2146): undefined reference to `_X509_free'
curl\lib/libcurl.a(ssluse.o):(.text+0x21c6): undefined reference to `_X509_free'
curl\lib/libcurl.a(ssluse.o):(.text+0x2274): undefined reference to `_X509_free'
curl\lib/libcurl.a(ssluse.o):(.text+0x2280): undefined reference to `_X509_free'
curl\lib/libcurl.a(ssluse.o):(.text+0x22b4): more undefined references to `_X509_free' follow
curl\lib/libcurl.a(ssluse.o):(.text+0x22c3): undefined reference to `_SSL_get_verify_result'
curl\lib/libcurl.a(ssluse.o):(.text+0x233e): undefined reference to `_GENERAL_NAMES_free'
curl\lib/libcurl.a(ssluse.o):(.text+0x23b7): undefined reference to `_ASN1_STRING_length'
curl\lib/libcurl.a(ssluse.o):(.text+0x23dc): undefined reference to `_CRYPTO_malloc'
curl\lib/libcurl.a(ssluse.o):(.text+0x23ec): undefined reference to `_ASN1_STRING_data'
curl\lib/libcurl.a(ssluse.o):(.text+0x2467): undefined reference to `_X509_verify_cert_error_string'
curl\lib/libcurl.a(ssluse.o):(.text+0x248e): undefined reference to `_X509_verify_cert_error_string'
curl\lib/libcurl.a(ssluse.o):(.text+0x24c9): undefined reference to `_GENERAL_NAMES_free'
curl\lib/libcurl.a(ssluse.o):(.text+0x251a): undefined reference to `_RAND_load_file'
curl\lib/libcurl.a(ssluse.o):(.text+0x251f): undefined reference to `_RAND_status'
curl\lib/libcurl.a(ssluse.o):(.text+0x256a): undefined reference to `_RAND_add'
curl\lib/libcurl.a(ssluse.o):(.text+0x2578): undefined reference to `_RAND_status'
curl\lib/libcurl.a(ssluse.o):(.text+0x2599): undefined reference to `_RAND_file_name'
curl\lib/libcurl.a(ssluse.o):(.text+0x25b2): undefined reference to `_RAND_load_file'
curl\lib/libcurl.a(ssluse.o):(.text+0x25b7): undefined reference to `_RAND_status'
curl\lib/libcurl.a(ssluse.o):(.text+0x267f): undefined reference to `_ERR_clear_error'
curl\lib/libcurl.a(ssluse.o):(.text+0x268a): undefined reference to `_SSL_connect'
[...]
curl\lib/libcurl.a(ssluse.o):(.text+0x3ecb): undefined reference to `_RAND_bytes'
curl\lib/libcurl.a(ftp.o):(.text+0xdac): undefined reference to `_bind@12'
curl\lib/libcurl.a(ftp.o):(.text+0xdbc): undefined reference to `_WSAGetLastError@0'
curl\lib/libcurl.a(ftp.o):(.text+0xdfc): undefined reference to `_htons@4'
curl\lib/libcurl.a(ftp.o):(.text+0xe4f): undefined reference to `_getsockname@12'
curl\lib/libcurl.a(ftp.o):(.text+0xe5f): undefined reference to `_WSAGetLastError@0'
curl\lib/libcurl.a(ftp.o):(.text+0xf2d): undefined reference to `_getsockname@12'
curl\lib/libcurl.a(ftp.o):(.text+0xf51): undefined reference to `_WSAGetLastError@0'
curl\lib/libcurl.a(ftp.o):(.text+0xfb4): undefined reference to `_getsockname@12'
curl\lib/libcurl.a(ftp.o):(.text+0xfc4): undefined reference to `_WSAGetLastError@0'
curl\lib/libcurl.a(ftp.o):(.text+0x10d1): undefined reference to `_listen@8'
curl\lib/libcurl.a(ftp.o):(.text+0x10dd): undefined reference to `_WSAGetLastError@0'
curl\lib/libcurl.a(ftp.o):(.text+0x11e9): undefined reference to `_ntohs@4'
curl\lib/libcurl.a(ftp.o):(.text+0x1249): undefined reference to `_ntohs@4'
curl\lib/libcurl.a(ftp.o):(.text+0x1429): undefined reference to `_getsockname@12'
curl\lib/libcurl.a(ftp.o):(.text+0x1478): undefined reference to `_accept@12'
curl\lib/libcurl.a(ftp.o):(.text+0x2bb9): undefined reference to `_WSAGetLastError@0'
curl\lib/libcurl.a(telnet.o):(.text+0x3fc): undefined reference to `_WSAStartup@8'
curl\lib/libcurl.a(telnet.o):(.text+0x432): undefined reference to `_WSACleanup@0'
curl\lib/libcurl.a(telnet.o):(.text+0xe1b): undefined reference to `_WSAGetLastError@0'
curl\lib/libcurl.a(telnet.o):(.text+0xe41): undefined reference to `_WSAGetLastError@0'
curl\lib/libcurl.a(telnet.o):(.text+0xf11): undefined reference to `_WSAGetLastError@0'
curl\lib/libcurl.a(telnet.o):(.text.unlikely+0x17b): undefined reference to `_send@16'
curl\lib/libcurl.a(telnet.o):(.text.unlikely+0x18b): undefined reference to `_WSAGetLastError@0'
curl\lib/libcurl.a(telnet.o):(.text.unlikely+0x3bb): undefined reference to `_ntohs@4'
curl\lib/libcurl.a(telnet.o):(.text.unlikely+0x3cb): undefined reference to `_ntohs@4'
curl\lib/libcurl.a(telnet.o):(.text.unlikely+0x5bd): undefined reference to `_htons@4'
curl\lib/libcurl.a(telnet.o):(.text.unlikely+0x5d2): undefined reference to `_htons@4'
curl\lib/libcurl.a(telnet.o):(.text.unlikely+0x6ae): undefined reference to `_send@16'
curl\lib/libcurl.a(telnet.o):(.text.unlikely+0x6ba): undefined reference to `_WSAGetLastError@0'
curl\lib/libcurl.a(telnet.o):(.text.unlikely+0x708): undefined reference to `_send@16'
curl\lib/libcurl.a(telnet.o):(.text.unlikely+0x714): undefined reference to `_WSAGetLastError@0'
curl\lib/libcurl.a(telnet.o):(.text.unlikely+0x853): undefined reference to `_send@16'
curl\lib/libcurl.a(telnet.o):(.text.unlikely+0x85f): undefined reference to `_WSAGetLastError@0'
curl\lib/libcurl.a(telnet.o):(.text.unlikely+0x9ad): undefined reference to `_send@16'
curl\lib/libcurl.a(telnet.o):(.text.unlikely+0x9b9): undefined reference to `_WSAGetLastError@0'
curl\lib/libcurl.a(ldap.o):(.text+0x221): undefined reference to `__imp__ldap_err2stringA'
curl\lib/libcurl.a(ldap.o):(.text+0x267): undefined reference to `__imp__ldap_msgfree'
curl\lib/libcurl.a(ldap.o):(.text+0x298): undefined reference to `__imp__ldap_unbind_s'
curl\lib/libcurl.a(ldap.o):(.text+0x6cb): undefined reference to `__imp__ldap_set_optionA'
curl\lib/libcurl.a(ldap.o):(.text+0x721): undefined reference to `__imp__ldap_simple_bind_sA'
curl\lib/libcurl.a(ldap.o):(.text+0x778): undefined reference to `__imp__ldap_search_sA'
curl\lib/libcurl.a(ldap.o):(.text+0x796): undefined reference to `__imp__ldap_err2stringA'
curl\lib/libcurl.a(ldap.o):(.text+0x825): undefined reference to `__imp__ldap_err2stringA'
curl\lib/libcurl.a(ldap.o):(.text+0x888): undefined reference to `__imp__ldap_set_optionA'
curl\lib/libcurl.a(ldap.o):(.text+0x8a3): undefined reference to `__imp__ldap_initA'
curl\lib/libcurl.a(ldap.o):(.text+0x8dd): undefined reference to `__imp__ldap_first_entry'
curl\lib/libcurl.a(ldap.o):(.text+0x91e): undefined reference to `__imp__ldap_get_dnA'
curl\lib/libcurl.a(ldap.o):(.text+0x9bd): undefined reference to `__imp__ldap_first_attributeA'
curl\lib/libcurl.a(ldap.o):(.text+0x9e9): undefined reference to `__imp__ldap_get_values_lenA'
curl\lib/libcurl.a(ldap.o):(.text+0xbc9): undefined reference to `__imp__ldap_value_free_len'
curl\lib/libcurl.a(ldap.o):(.text+0xc1e): undefined reference to `__imp__ldap_memfreeA'
curl\lib/libcurl.a(ldap.o):(.text+0xc3d): undefined reference to `__imp__ldap_next_attributeA'
curl\lib/libcurl.a(ldap.o):(.text+0xc56): undefined reference to `__imp__ldap_memfreeA'
curl\lib/libcurl.a(ldap.o):(.text+0xc71): undefined reference to `__imp__ber_free'
curl\lib/libcurl.a(ldap.o):(.text+0xc86): undefined reference to `__imp__ldap_next_entry'
curl\lib/libcurl.a(ldap.o):(.text+0xcaf): undefined reference to `__imp__ldap_value_free_len'
curl\lib/libcurl.a(ldap.o):(.text+0xcbc): undefined reference to `__imp__ldap_memfreeA'
curl\lib/libcurl.a(ldap.o):(.text+0xccb): undefined reference to `__imp__ldap_memfreeA'
curl\lib/libcurl.a(ldap.o):(.text+0xcea): undefined reference to `__imp__ber_free'
curl\lib/libcurl.a(tftp.o):(.text+0x210): undefined reference to `_sendto@24'
curl\lib/libcurl.a(tftp.o):(.text+0x29b): undefined reference to `_sendto@24'
[...]
curl\lib/libcurl.a(ssh.o):(.text+0x46a9): undefined reference to `_libssh2_knownhost_init'
curl\lib/libcurl.a(ssh.o):(.text+0x46cd): undefined reference to `_libssh2_knownhost_readfile'
curl\lib/libcurl.a(curl_rtmp.o):(.text+0x24): undefined reference to `_RTMP_Close'
curl\lib/libcurl.a(curl_rtmp.o):(.text+0x2c): undefined reference to `_RTMP_Free'
curl\lib/libcurl.a(curl_rtmp.o):(.text+0xbc): undefined reference to `_setsockopt@20'
curl\lib/libcurl.a(curl_rtmp.o):(.text+0xcf): undefined reference to `_RTMP_Connect1'
curl\lib/libcurl.a(curl_rtmp.o):(.text+0x13d): undefined reference to `_RTMP_Write'
curl\lib/libcurl.a(curl_rtmp.o):(.text+0x15e): undefined reference to `_RTMP_Alloc'
curl\lib/libcurl.a(curl_rtmp.o):(.text+0x16c): undefined reference to `_RTMP_Init'
curl\lib/libcurl.a(curl_rtmp.o):(.text+0x17c): undefined reference to `_RTMP_SetBufferMS'
curl\lib/libcurl.a(curl_rtmp.o):(.text+0x190): undefined reference to `_RTMP_SetupURL'
curl\lib/libcurl.a(curl_rtmp.o):(.text+0x1ac): undefined reference to `_RTMP_Free'
curl\lib/libcurl.a(curl_rtmp.o):(.text+0x1eb): undefined reference to `_RTMP_Read'
curl\lib/libcurl.a(curl_rtmp.o):(.text+0x24e): undefined reference to `_RTMP_ConnectStream'
curl\lib/libcurl.a(select.o):(.text+0x2e): undefined reference to `_WSASetLastError@4'
curl\lib/libcurl.a(select.o):(.text+0x2ae): undefined reference to `_select@20'
curl\lib/libcurl.a(select.o):(.text+0x2bd): undefined reference to `_WSAGetLastError@0'
curl\lib/libcurl.a(select.o):(.text+0x354): undefined reference to `___WSAFDIsSet@8'
curl\lib/libcurl.a(select.o):(.text+0x374): undefined reference to `___WSAFDIsSet@8'
curl\lib/libcurl.a(select.o):(.text+0x3b4): undefined reference to `___WSAFDIsSet@8'
curl\lib/libcurl.a(select.o):(.text+0x3d1): undefined reference to `___WSAFDIsSet@8'
curl\lib/libcurl.a(select.o):(.text+0x42f): undefined reference to `___WSAFDIsSet@8'
curl\lib/libcurl.a(select.o):(.text+0x445): more undefined references to `___WSAFDIsSet@8' follow
curl\lib/libcurl.a(select.o):(.text+0x77d): undefined reference to `_select@20'
curl\lib/libcurl.a(select.o):(.text+0x78c): undefined reference to `_WSAGetLastError@0'
curl\lib/libcurl.a(select.o):(.text+0x849): undefined reference to `___WSAFDIsSet@8'
curl\lib/libcurl.a(select.o):(.text+0x863): undefined reference to `___WSAFDIsSet@8'
curl\lib/libcurl.a(select.o):(.text+0x884): undefined reference to `___WSAFDIsSet@8'
curl\lib/libcurl.a(content_encoding.o):(.text+0x170): undefined reference to `_inflate'
curl\lib/libcurl.a(content_encoding.o):(.text+0x18c): undefined reference to `_inflateEnd'
curl\lib/libcurl.a(content_encoding.o):(.text+0x1ac): undefined reference to `_inflateInit2_'
curl\lib/libcurl.a(content_encoding.o):(.text+0x224): undefined reference to `_inflateEnd'
curl\lib/libcurl.a(content_encoding.o):(.text+0x27e): undefined reference to `_inflateEnd'
curl\lib/libcurl.a(content_encoding.o):(.text+0x294): undefined reference to `_inflateEnd'
curl\lib/libcurl.a(content_encoding.o):(.text+0x2be): undefined reference to `_inflateEnd'
curl\lib/libcurl.a(content_encoding.o):(.text+0x2ce): undefined reference to `_inflateEnd'
curl\lib/libcurl.a(content_encoding.o):(.text+0x33e): undefined reference to `_inflateInit_'
curl\lib/libcurl.a(content_encoding.o):(.text+0x472): undefined reference to `_zlibVersion'
curl\lib/libcurl.a(content_encoding.o):(.text+0x4b0): undefined reference to `_inflateInit2_'
curl\lib/libcurl.a(content_encoding.o):(.text+0x4f8): undefined reference to `_inflateInit2_'
curl\lib/libcurl.a(content_encoding.o):(.text+0x58c): undefined reference to `_inflateEnd'
curl\lib/libcurl.a(content_encoding.o):(.text+0x5c9): undefined reference to `_inflateEnd'
curl\lib/libcurl.a(content_encoding.o):(.text+0x6ca): undefined reference to `_inflateEnd'
curl\lib/libcurl.a(nonblock.o):(.text+0x2a): undefined reference to `_ioctlsocket@12'
curl\lib/libcurl.a(md5.o):(.text+0x15): undefined reference to `_MD5_Init'
curl\lib/libcurl.a(md5.o):(.text+0x3b): undefined reference to `_MD5_Update'
curl\lib/libcurl.a(md5.o):(.text+0x4e): undefined reference to `_MD5_Final'
curl\lib/libcurl.a(md5.o):(.rdata+0x0): undefined reference to `_MD5_Init'
curl\lib/libcurl.a(md5.o):(.rdata+0x4): undefined reference to `_MD5_Update'
curl\lib/libcurl.a(md5.o):(.rdata+0x8): undefined reference to `_MD5_Final'
curl\lib/libcurl.a(md5.o):(.rdata+0x14): undefined reference to `_MD5_Init'
curl\lib/libcurl.a(md5.o):(.rdata+0x18): undefined reference to `_MD5_Update'
curl\lib/libcurl.a(md5.o):(.rdata+0x1c): undefined reference to `_MD5_Final'
curl\lib/libcurl.a(curl_gethostname.o):(.text+0x19): undefined reference to `_gethostname@8'
curl\lib/libcurl.a(socks_sspi.o):(.text+0x2e4): undefined reference to `_htons@4'
curl\lib/libcurl.a(socks_sspi.o):(.text+0x427): undefined reference to `_ntohs@4'
curl\lib/libcurl.a(socks_sspi.o):(.text+0x811): undefined reference to `_htons@4'
curl\lib/libcurl.a(socks_sspi.o):(.text+0xc5c): undefined reference to `_htons@4'
curl\lib/libcurl.a(socks_sspi.o):(.text+0xd7e): undefined reference to `_ntohs@4'
collect2.exe: error: ld returned 1 exit status

编辑:我还尝试下载其网站上提供的Windows OpenSSL软件包并将其包含在内 - 无需更改。

编辑:它终于有效了!解决方案是使用32位cURL包并将这些参数传递给编译器:

g++ -o Test.exe Test.cpp -DCURL_STATICLIB -I curl\include -L curl\lib -lcurldll -lssh2 -lidn -lrtmp -lssl -lcrypto -lz -lws2_32 -lwldap32

1 个答案:

答案 0 :(得分:1)

由于一切设置正确,我看到两个解决方案:

删除-DCURL_STATICLIB或将-static添加到命令行。

修改 花了一些时间,但看起来你有一个32位的Mingw和一个64位的libcurl。下载32位libcurl并重试。