簡體   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