简体   繁体   English

带有 x86-64-w64-mingw32-g++ 未定义引用的 libcurl。 g++ 工作正常

[英]libcurl with x86-64-w64-mingw32-g++ undefined reference. g++ works fine

I am trying to cross-compile simple C++ program for Windows using libcurl and Linux.我正在尝试使用 libcurl 和 Linux 为 Windows 交叉编译简单的 C++ 程序。 I am using the following code:我正在使用以下代码:

x86_64-w64-mingw32-g++ -DCURL_STATICLIB curl_example.cpp -oe -lcurl

However, I get the following error:但是,我收到以下错误:

/usr/bin/x86_64-w64-mingw32-ld: /tmp/ccNXyMyw.o:curl_example.cpp:(.text+0xa5): undefined reference to `curl_easy_setopt'
/usr/bin/x86_64-w64-mingw32-ld: /tmp/ccNXyMyw.o:curl_example.cpp:(.text+0xbd): undefined reference to `curl_easy_setopt'
/usr/bin/x86_64-w64-mingw32-ld: /tmp/ccNXyMyw.o:curl_example.cpp:(.text+0xc9): undefined reference to `curl_easy_perform'
/usr/bin/x86_64-w64-mingw32-ld: /tmp/ccNXyMyw.o:curl_example.cpp:(.text+0xd8): undefined reference to `curl_easy_cleanup'
collect2: error: ld returned 1 exit status

I include curl like this: #include <curl/curl.h>我像这样包含 curl: #include <curl/curl.h>

And I've tried every suggested solution to the problem I could find.我已经尝试了所有我能找到的问题的建议解决方案。 Also I have to note, that if I use g++, it works fine:另外我必须注意,如果我使用 g++,它工作正常:

g++ -DCURL_STATICLIB curl_example.cpp -oe -lcurl

What could be the issue?可能是什么问题?

I had to compile curl for the x86_64-w64-mingw32, as @KamilCuk suggested.正如@KamilCuk 建议的那样,我必须为 x86_64-w64-mingw32 编译 curl。 In order to do that, I configured with为了做到这一点,我配置了

./configure --build x86_64-pc-linux-gnu --host x86_64-w64-mingw32 --prefix=/usr/x86_64-w64-mingw32

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

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