c++ - cURL交叉编译

标签 c++ c

如何在 Linux 上交叉编译 Windows 的“cURL”(实际上使用 kali)?或者是否有已经构建了交叉编译环境或易于构建交叉编译环境的linux发行版? 请帮忙!

我让 Mingw 可以正常使用其包含目录中已有的头文件。现在我编译了 cURL 并验证了它在 Mingw 的 include 目录中的存在。但现在当我包括<curl/curl.h>时在我的代码中,这是我在编译时遇到的错误:

/tmp/ccsrpc1o.o:https.c:(.text+0x1c): undefined reference to `__imp__curl_global_init'
/tmp/ccsrpc1o.o:https.c:(.text+0x26): undefined reference to `__imp__curl_easy_init'
/tmp/ccsrpc1o.o:https.c:(.text+0x4a): undefined reference to `__imp__curl_easy_setopt'
/tmp/ccsrpc1o.o:https.c:(.text+0x5a): undefined reference to `__imp__curl_easy_perform'
/tmp/ccsrpc1o.o:https.c:(.text+0x73): undefined reference to `__imp__curl_easy_strerror'
/tmp/ccsrpc1o.o:https.c:(.text+0xb2): undefined reference to `__imp__curl_easy_cleanup'
/tmp/ccsrpc1o.o:https.c:(.text+0xbc): undefined reference to `__imp__curl_global_cleanup'
collect2: ld returned 1 exit status

最佳答案

首先使用以下命令交叉编译 cURL:

$ ./configure --host=i586-mingw32msvc --enable-http --with-zlib --with-winssl
$ make
$ make install

现在您可以编译代码了:

$ i58​​6-mingw32msvc-gcc -o https.exe https.c -lcurl

$ i586-mingw32msvc-gcc -o https.exe https.c /usr/i586-mingw32msvc/lib/libcurl.dll.a

关于c++ - cURL交叉编译,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31260830/

相关文章:

c++ - C++ 中方法的 const 和非 const 版本之间的区别

c++ - 如何声明一个指向二维浮点矩阵的指针?

c - 用于字符串连接的 snprintf

c++ - 隐式转换被认为是一个坏概念吗?

javascript - C++/JS 中的 Switch 语句变体

c++ - 如何从 X Y Z 旋转中找到四元数的 vector

c - 为什么我在窗口 C 编程中得到 "a.exe"而不是 "a.out"

c - 可能是一个愚蠢的,经常被问到的错误,涉及 C 中的数组

c - 段错误 : 11 with large array

c - unix "clear"未设置 TERM 环境变量