简体   繁体   English

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

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

I have compiled libcurl using mingw32 and am trying to link it with my program using mingw32 for a Windows system from my Linux machine.我已经使用 mingw32 编译了 libcurl,并试图将它与我的程序使用 mingw32 链接到我的 Linux 机器上的 Windows 系统。

I was outputted the files, libcurl-4.dll libcurl.a libcurl.la libcurl.lai.我被输出了文件,libcurl-4.dll libcurl.a libcurl.la libcurl.lai。

I have included them in my mingw32 libs folder at: /usr/x86_64-w64-mingw32/lib我已将它们包含在我的 mingw32 libs 文件夹中:/usr/x86_64-w64-mingw32/lib

I was able to find a few other topics on linking with the libstdc++ and libgcc to take care dependency errors while executed but when trying to add libcurl.a it will not compile period.我能够找到一些关于与 libstdc++ 和 libgcc 链接的其他主题,以在执行时处理依赖项错误,但在尝试添加 libcurl.a 时,它不会编译期。

I used the following:我使用了以下内容:

$ x86_64-w64-mingw32-g++ main.cpp -o hello.exe -static-libgcc -static-libstdc++ -static "/usr/x86_64-w64-mingw32/lib/libcurl.a" -lpthread

However, I cannot not get it to use the libcurl.a and am continuing to receive these errors.但是,我无法让它使用 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

What am I doing wrong?.我究竟做错了什么?。 I can not get past this.我无法克服这一点。 I know it has to be some stupid issue.我知道这一定是一些愚蠢的问题。

Thank you.谢谢你。

我能够通过指定 -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