gcc - 在 MAC 上交叉编译 C 时的 libcurl 问题

标签 gcc cross-compiling openwrt toolchain

我在 MAC OS 上使用 OpenWRT 的工具链交叉编译 C。 C 程序依赖于我已经安装的 libcurl。但是,当我构建 C 程序时,我收到如下错误消息。

1.在MAC上安装libcurl

brew install curl 

2.使用工具栏链交叉编译main.c

toolchain-mips_34kc_gcc-4.8-linaro_uClibc-0.9.33.2/bin/mips-openwrt-linux-uclibc-gcc -I/usr/local/opt/curl/include main.c

3.编译错误

In file included from /usr/local/opt/curl/include/curl/curl.h:35:0,
             from main.c:4:
/usr/local/opt/curl/include/curl/curlrules.h:142:3: error: size of array '__curl_rule_01__' is negative
__curl_rule_01__
^
/usr/local/opt/curl/include/curl/curlrules.h:152:3: error: size of array '__curl_rule_02__' is negative

curl_rule_02

最佳答案

您需要使用 mips 工具链交叉编译curl/libcurl。 (事实上​​,您应该对所有其他依赖项执行此操作)

您已经使用brew安装了curl,这实际上将x64版本的curl安装到您的系统上。

curl 中有一些在编译时生成的 header (我认为是curlbuild.h) 这些 header 根据架构定义宏,例如CURL_SIZEOF_LONG

由于您使用curl header (为x64 arch准备的)来构建mips应用程序,因此无法找到正确的CURL_SIZEOF_LONG宏,导致-1作为值。

此外,在某些时候您将需要链接 libcurl 库。如果您使用 mips 工具链,您当前的库将永远不会链接。因此,请先尝试交叉编译curl并使用该版本。

关于gcc - 在 MAC 上交叉编译 C 时的 libcurl 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25585637/

相关文章:

android - 如何在Android上使用strace?

gcc - 谁能解释一下 gcc 交叉编译器的命名约定?

c++ - Boost-Build:从 Linux 构建 Windows 可执行文件

lua - 如何映射多个配置文件

testing - OpenWrt 中的谷歌测试

c - fltk 提示 Windows 上的 gcc

找不到在另一个动态库中定义的符号

c++ - 在命名空间 std 中找不到 GCC std::thread

php - 如何在openwrt中安装配置php

c++ - 将指针传递给由 exec() 生成的进程