编译c-ares库从失败到成功的过程
c-ares-master: apt-get install libtool   
####https://github.com/c-ares/c-ares

==============================

失败的过程;

{
.host配错了
./configure --host=x86_64-pokysdk-linux --target=arm-poky-linux-gnueabi --prefix=/root/work/lib_arm/c-ares
make root@ubuntu:~/work/share/mqtt/c-ares-master# find . -name "*.so*"
./.libs/libcares.so.2.2.
./.libs/libcares.so
./.libs/libcares.so.
root@ubuntu:~/work/share/mqtt/c-ares-master# file ./.libs/libcares.so.2.2.
./.libs/libcares.so.2.2.: ELF -bit LSB shared object, x86-, version (SYSV), dynamically linked, BuildID[sha1]=0e375b908f27eba4b86bd572c4716c1671b4b849, not stripped . arm-poky-linux-gnueabi-gcc 交叉编译工具的配置不适合代码
ld: error: a.out uses VFP register arguments, /tmp/ccNTGLwS.o does not http://stackoverflow.com/questions/9753749/arm-compilation-error-vpf-registered-used-by-executable-not-object-file triplet indicates that your compiler is configured for the soft-float ABI.
but part of your lib or *.o is using soft-float ABI.
solved by exporting-mfloat-abi=hard to flags root@ubuntu:~/work/share/mqtt/c-ares-master# ./configure --host=arm-poky-linux-gnueabi --prefix=/root/work/lib_arm/c-ares
checking whether to enable maintainer-specific portions of Makefiles... no
checking whether make supports nested variables... yes
checking whether to enable debug build options... no
checking whether to enable compiler optimizer... not specified (assuming yes)
checking whether to enable strict compiler warnings... no
checking whether to enable compiler warnings as errors... no
checking whether to enable curl debug memory tracking... no
checking whether to enable hiding of library internal symbols... yes
checking whether to expose internal static functions for testing... no
checking for path separator... :
checking for sed... /bin/sed
checking for grep... /bin/grep
checking for egrep... /bin/grep -E
checking for arm-poky-linux-gnueabi-ar... /opt/poky/1.7/sysroots/x86_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi/arm-poky-linux-gnueabi-ar
checking for a sed that does not truncate output... (cached) /bin/sed
checking whether to build with code coverage support... no
checking build system type... x86_64-pc-linux-gnu
checking host system type... arm-poky-linux-gnueabi
checking for a BSD-compatible install... /usr/bin/install -c
checking for arm-poky-linux-gnueabi-gcc... arm-poky-linux-gnueabi-gcc
checking whether the C compiler works... no
configure: error: in '/root/work/share/mqtt/c-ares-master':
configure: error: C compiler cannot create executables
See 'config.log' for more details vi config.log
configure:: $? =
configure:: checking whether the C compiler works
configure:: arm-poky-linux-gnueabi-gcc conftest.c >&
/opt/poky/1.7/sysroots/x86_64-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/4.9./
ld: error: a.out uses VFP register arguments, /tmp/ccNTGLwS.o does not //重点在这里
/opt/poky/1.7/sysroots/x86_64-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/4.9./
ld: failed to merge target specific data of file /tmp/ccNTGLwS.o
collect2: error: ld returned exit status
configure:: $? =
configure:: result: no
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME "c-ares"
| #define PACKAGE_TARNAME "c-ares"
| #define PACKAGE_VERSION "-"
| #define PACKAGE_STRING "c-ares -"
| #define PACKAGE_BUGREPORT "c-ares mailing list: http://cool.haxx.se/mailman/listinfo/c-ares"
| #define PACKAGE_URL ""
| #define OS "arm-poky-linux-gnueabi"
| /* end confdefs.h. */
|
| int main (void)
| {
|
| ;
| return ;
| }
configure:: error: in '/root/work/share/mqtt/c-ares-master':
configure:: error: C compiler cannot create executables   解决办法: CFLAGS加一个-mfloat-abi=hard
}

正确步骤
{
    cd c-ares-master/
    ./buildconf   
    export CFLAGS="-mfloat-abi=hard -g0 -O2 -Wno-system-headers "
    ./configure  --host=arm-poky-linux-gnueabi  --prefix=/root/work/lib_arm/c-ares
    make

root@ubuntu:~/work/share/mqtt/c-ares-master# find . -name "*.so*"
    ./.libs/libcares.so.2.2.0
    ./.libs/libcares.so
    ./.libs/libcares.so.2
    root@ubuntu:~/work/share/mqtt/c-ares-master# file ./.libs/libcares.so.2.2.0
    ./.libs/libcares.so.2.2.0: ELF 32-bit LSB shared object, ARM, EABI5 version 1 (SYSV), dynamically linked, BuildID[sha1]=c170250d2d9eae99d07a9f71face684ee50c7ef7, not stripped
}

开源组件的常见配置:
{
查看目录下面的README,INSTALL这些文档,看怎么去build。
    ./buildconf
    ./configure --host=x86_64-pokysdk-linux --target=arm-poky-linux-gnueabi --prefix=/root/work/lib_arm/c-ares

make有时候可以手动指定CC,AR,LD等编译选项,但是要根据组件的Makefile和config文件是否用到,名字是不是这个,不能随意猜测
    make CC="arm-poky-linux-gnueabi-gcc" AR="arm-poky-linux-gnueabi-ar r" RANLIB="arm-poky-linux-gnueabi-ranlib"  
    make CC="arm-poky-linux-gnueabi-gcc" AR="arm-poky-linux-gnueabi-ar r" RANLIB="arm-poky-linux-gnueabi-ranlib" install

有可能需要配置下某些编译选项以使得编译器配置和组件代码的要求相匹配
    export CFLAGS="-mfloat-abi=hard -g0 -O2 -Wno-system-headers "

}

参考:
build、host和target
http://www.cnblogs.com/electron/p/3548039.html    
{
  我们以 gcc 为例子来 讲解 这三者的作用
  ./configure --build=编译平台 --host=运行平台 --target=目标平台 [各种编译参数]
  来配置gcc的源代码,以让其编译出我们需要的gcc编译器。

--build:
        表示目前我们正在运行的平台名称是什么,如果当前我们是在intel的pentium机器中编译该系统,那么我们的--build就可能是 i686-pc-linux-gnu,当然如果我们在其它种类的机器上编译那么这个build就应该是那个机器所对应的平台名称。
        该参数在不指定的情况下将自动尝试猜测目前平台的名称。

--host:
        表示我们把这个编译好的gcc在什么样的平台下运行,在交叉编译过程中这个需要我们来指定,因为机器自己是不能知道我们心里是怎么想的,那 么我们可以明确的告诉它,我们要做出来的程序是运行在“龙芯”上的,但是目前还不能直接指定“龙芯”,因此我们这里指定为mips64el- unknown-linux-gnu(如果你省点事情那么就用这个名字好了,如果你想用个有个性的名字,那么请你想明白它的含义再动手,并且做好后面的过 程需要多出一些手续的麻烦的心理准备)。
        --host也可以不指定,那么host将自动使用build来定义自己,不过那将不再是交叉编译。
        注:--build和--host在不同的时候就被配置文件认定为交叉编译方式。

--target:
        该参数的目的是让配置程序知道这个软件被编译后使用来处理什么平台上的文件的。

总结一下:
        build:自动测试在用平台名称,若无法检测出来则需要指定。
        host:若无指定,自动使用build的结果。
        build和host相同时表示本地编译,若不相同则表示交叉编译。
        target:表示需要处理的目标平台名称,若无指定使用host相同名称,gcc、binutils等于平台指令相关软件有此参数,多数软件此参数无用处。        
        
}

如何交叉编译开源库-->编译c-ares库从失败到成功的过程[ocean]的更多相关文章

  1. 将pugixml库编译成动态库的做法

    作者:朱金灿 来源:http://blog.csdn.net/clever101 pugixml库默认是编译成静态库的.要把pugixml库编译成一个动态库,需要对代码做一些修改,具体是将 // If ...

  2. 使用CMake编译跨平台静态库

    在开始介绍如何使用CMake编译跨平台的静态库之前,先讲讲我在没有使用CMake之前所趟过的坑.因为很多开源的程序,比如png,都是自带编译脚本的.我们可以使用下列脚本来进行编译:   . / con ...

  3. 配置自己的OpenGL库,glew、freeglut库编译,库冲突解决(附OpenGL Demo程序)

    平台:Windows7,Visual C++ 2010 1. 引言 实验室的一个项目,用到OpenGL进行实时绘制,还用到一些其他的库,一个困扰我很久的问题就是编译时遇到的各种符号未定义,符号重定义之 ...

  4. 表格树控件QtTreePropertyBrowser编译成动态库(设计师插件)

    目录 一.回顾 二.动态库编译 1.命令行编译动态库和测试程序 2.vs工具编译动态库和测试程序 3.安装文档 4.测试文档 三.设计师插件编译 1.重写QDesignerCustomWidgetIn ...

  5. 将STM32的标准库编译成lib使用【图文】

    以前一直使用STM32的标准库,需要一步步地将代码加进去,将编译选项设置好,然后再编译整个工程. 这个编译过程是一个相当慢的过程!完全编译大约需要一支烟的时间.每次建立工程都这么编译,是一个相当浪费时 ...

  6. 将STM32的标准库编译成lib

    转载自:http://www.cnblogs.com/zyqgold/p/3189719.html 以前一直使用STM32的标准库,需要一步步地将代码加进去,将编译选项设置好,然后再编译整个工程. 这 ...

  7. 转载:将STM32的标准库编译成lib使用【图文】

    from:http://www.cnblogs.com/zyqgold/p/3189719.html 百度上边也有不少关于lib文件的文章,恰巧看到该博文,感觉该博文的条理清晰,步骤明确,故复制到这个 ...

  8. C/C++ 跨平台交叉编译、静态库/动态库编译、MinGW、Cygwin、CodeBlocks使用原理及链接参数选项

    目录 . 引言 . 交叉编译 . Cygwin简介 . 静态库编译及使用 . 动态库编译及使用 . MinGW简介 . CodeBlocks简介 0. 引言 UNIX是一个注册商标,是要满足一大堆条件 ...

  9. [转]Android开源项目第二篇——工具库篇

    本文为那些不错的Android开源项目第二篇--开发工具库篇,主要介绍常用的开发库,包括依赖注入框架.图片缓存.网络相关.数据库ORM建模.Android公共库.Android 高版本向低版本兼容.多 ...

随机推荐

  1. 微软 Office 2010 SP2 正式版下载大全(含简中)

    7月24日消息,微软正式为 Office 2010 和 SharePoint 2010 系列产品发布 SP 2服务包,带来重要更新和修复.除了提供产品补丁,SP2服务包还将提升产品的稳定性.性能以及安 ...

  2. c++ new长度为0的数组

    在程序中发现一下代码: int CHmcVideoMgt ::OnGetDiskRunningInfo( SOCKETPARAM *pSocketInfo ,Json:: Value Param ) ...

  3. openstack core components use 总结

    1,附加volume(块存储,云硬盘)到vmInstances(虚拟机实列)

  4. 新iPhone开售现场:土豪金火了

    今日苹果在全球范围内开始正式发售iPhone 5s与5c手机.在中国王府井苹果零售店,首位购机者李先生在今早4点50分便在此等候. 现场未发现黄牛 本次苹果在中国大陆的自有零售店渠道首批iPhone ...

  5. WKWebView与sessionID的因果

    问题描述:在webView中点击下载按钮后,下载成功文件,然后再去点击上传文件,这时候服务器会报用户未登录错误. 暂时分析的原因是WKWebView在下载后cookie会保存服务器产生的session ...

  6. HDU 3046 Pleasant sheep and big big wolf(最小割)

    HDU 3046 Pleasant sheep and big big wolf 题目链接 题意:一个n * m平面上,1是羊.2是狼,问最少要多少围墙才干把狼所有围住,每有到达羊的路径 思路:有羊和 ...

  7. iOS 使用Method Swizzling隐藏Status Bar

    在iOS 6中,隐藏Status Bar很的简单. // iOS 6及曾经,隐藏状态栏 [[UIApplication sharedApplication] setStatusBarHidden:YE ...

  8. 怎么增加照片的KB大小

    之前都是要想办法压缩图片的大小 今天有人发来一张1.8MB的图片让我帮忙调到30MB左右 一下子放大这么多着实有点茫然 之后想到了一个办法 首先把图片占用体积变大,是不会增加清晰度的,而减小占用体积却 ...

  9. BZOJ 2716: [Violet 3]天使玩偶( CDQ分治 + 树状数组 )

    先cdq分治, 然后要处理点对答案的贡献, 可以以询问点为中心分成4个区域, 然后去掉绝对值(4种情况讨论), 用BIT维护就行了. --------------------------------- ...

  10. C++之继承和动态内存分配

    C++之继承和动态内存分配         如果基类使用动态内存分配,并重新定义赋值和复制构造函数,这将如何影响派生类的实现呢?这取决于派生类的属性,如果派生类也使用动态内存分配,这将如何实现呢?这种 ...