我使用mingw32编译了libcurl,并尝试使用mingw32将其与我的程序链接到我的Linux机器上的Windows系统.
我输出了libcurl-4.dll libcurl.a libcurl.la libcurl.lai文件.
我把它们包含在我的mingw32 libs文件夹中:/usr/x86_64-w64-mingw32 / lib
我能够找到一些关于链接libstdc和libgcc的其他主题,以便在执行时注意依赖性错误,但是当尝试添加libcurl.a时,它将不会编译期间.
我使用了以下内容:
$x86_64-w64-mingw32-g++ main.cpp -o hello.exe -static-libgcc -static-libstdc++ -static "/usr/x86_64-w64-mingw32/lib/libcurl.a" -lpthread
但是,我不能让它使用libcurl.a并继续收到这些错误.
/tmp/ccIceRus.o:main.cpp:(.text+0xde): undefined reference to `__imp_curl_easy_init'
/tmp/ccIceRus.o:main.cpp:(.text+0x106): undefined reference to `__imp_curl_easy_setopt'
/tmp/ccIceRus.o:main.cpp:(.text+0x122): undefined reference to `__imp_curl_easy_setopt'
/tmp/ccIceRus.o:main.cpp:(.text+0x13e): undefined reference to `__imp_curl_easy_setopt'
/tmp/ccIceRus.o:main.cpp:(.text+0x159): undefined reference to `__imp_curl_easy_setopt'
/tmp/ccIceRus.o:main.cpp:(.text+0x169): undefined reference to `__imp_curl_easy_perform'
/tmp/ccIceRus.o:main.cpp:(.text+0x180): undefined reference to `__imp_curl_easy_strerror'
/tmp/ccIceRus.o:main.cpp:(.text+0x197): undefined reference to `__imp_curl_easy_cleanup'
/usr/bin/x86_64-w64-mingw32-ld: /tmp/ccIceRus.o: bad reloc address 0x80 in section `.xdata'
collect2: error: ld returned 1 exit status
我究竟做错了什么?.我无法超越这个.我知道它必须是一些愚蠢的问题.
谢谢.
解决方法:
我能够通过指定-DCURL_STATICLIB以及链接其他一些依赖项来解决问题.
x86_64-w64-mingw32-g++ main.cpp -o hello.exe -DCURL_STATICLIB -static -lstdc++ -lgcc -lpthread -lcurl -lwldap32 -lws2_32
标签:c-2,linux,linker,libcurl,mingw-w64
来源: https://codeday.me/bug/20190623/1274290.html