热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

交叉编译libcurl用于arm-linux-gnueabi-gcc-Crosscompilelibcurlforarm-linux-gnueabi-gcc

Ihavebeentryingtocrosscompilelibcurl7.35.0fromubuntueclipseforarm-linux-gnueabi-gcc++.

I have been trying to cross compile libcurl 7.35.0 from ubuntu eclipse for arm-linux-gnueabi-gcc++. I have included -lcurl optons in GCC++ linker. when I am trying to compile the code in G++ compiler for the below code everything is going well and no error was there after building.

我一直在尝试从ubuntu eclipse交叉编译libcurl 7.35.0以获得arm-linux-gnueabi-gcc+。我在GCC+ linker中包含了-lcurl optons。当我试图用g++编译下面代码的代码时,一切都进行得很顺利,构建之后没有错误。

#include 
#include 
using namespace std;

int main()
{
     return
}

But when I am trying to cross compile using arm-linux-gnueabi-gcc++ but trying to Build this produces compilation errors:

但是,当我尝试使用arm-linux-gnueabi-gcc++ ++进行交叉编译时,尝试构建它会产生编译错误:

/usr/include/curl/curlrules.h:143:41: error: size of array ‘curl_rule_01’ is negative /usr/include/curl/curlrules.h:153:53: error: size of array ‘curl_rule_02’ is negative

/usr/include/curl/curlrules.h:143:41: error: array ' curl_rule_01 '的大小为负/usr/ include/curlrules .h:153:53:错误:数组的大小curl_rule_02是负数。

Kindly help me to guide how to cross compile libcurl for ARM.

请帮助我指导如何交叉编译libcurl。

1 个解决方案

#1


3  

I remember back when I had to cross-compile curl... what a day! What curl is doing is fairly odd, but yet clever.

我记得当我要交叉编译curl时……多糟糕的一天!curl正在做的事情相当奇怪,但却很聪明。

if you look at that line you see this:

如果你看这条线,你会看到:

typedef char
  __curl_rule_01__
    [CurlchkszEQ(long, CURL_SIZEOF_LONG)];

and if you look at CurlchkszEQ, you get

如果你看CurlchkszEQ,你会得到

#define CurlchkszEQ(t, s) sizeof(t) == s ? 1 : -1

So this routine is enforcing that sizeof(long) == CURL_SIZEOF_LONG, if it does not, it will put a negative number in that array initializer and cause the build to fail.

这个例程执行sizeof(long) == CURL_SIZEOF_LONG,如果没有,它会在数组初始化器中输入一个负数,导致构建失败。

Here's the deal, CURL_SIZEOF_LONG is defined in curlbuild.h, and it is defined to 8... on an x86_64 machine. That is, in /usr/include/curl/curlbuild.h it is set to 8. You don't care about x86_64 though! You're compiling for arm... a 32-bit architecture where sizeof(long) == 4, not 8 and CURL_SIZEOF_LONG is improperly set to 8! So it appears your compiler is picking up on the system wide, x86_64 curl header files at /usr/include/... rather than the headers for the cross compiler! (for example mine are in /opt/cross/arm-unknown-linux-gnueabi/include/..., but yours probably are not).

这里的问题是,CURL_SIZEOF_LONG在curlbuild中定义。h,定义为8…在一个x86_64机器。也就是说,在/usr/include/curl/curlbuild.h它被设为8。但是你不关心x86_64 !你编译的手臂……一个32位的架构,其中sizeof(long) = 4,而不是8和CURL_SIZEOF_LONG被错误地设置为8!因此,您的编译器似乎正在系统范围内获取x86_64 curl头文件(/usr/ include/…)。而不是交叉编译器的头文件!(例如我的是in /opt/cross/arm-unknown-linux-gnueabi/include/…),但你的可能不是)。

So when compiling the compiler resovles that sizeof(long) == 4 != CURL_SIZEOF_LONG and properly crashes. The way to fix the problem is simple in theory, just change your configuration in your compiler to use the cross-compiler includes. In Eclipse, I am not sure how to do it, though I am sure it is possible.

因此,当编译器编译时,sizeof(long) == 4 != CURL_SIZEOF_LONG并正确地崩溃。解决这个问题的方法在理论上很简单,只需更改编译器中的配置以使用交叉编译器include。在Eclipse中,我不确定如何实现它,尽管我确信这是可能的。

You might find it easier just to build curl from the terminal like so:

你可能会发现从终端构建旋度更简单:

curl $ ./configure --host=arm-linux-gnueabi --prefix=/path/to/your/arm-linux-gnueabi/arm-linux-gnueabi
... configure stuff ...
curl $ make && make install

推荐阅读
author-avatar
跑车世界Y
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有