Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
408 views
in Technique[技术] by (71.8m points)

linux - 带有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?

(可能是什么问题?)

  ask by e.e translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...