繁体   English   中英

在 Linux for Windows 下与 mingw32 交叉编译时链接 libcurl

[英]Linking libcurl while cross compiling with mingw32 under Linux for Windows

我已经使用 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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM