在海思平台下,交叉编译boost库、thrift库、openssl库、libevent库

编译openssl:

1. 下载openssl源码,我这里的为openssl-1.0.2o.tar.gz

2. 解压到指定目录,tar xzf openssl-1.0.2o.tar.gz -C /home/up

3. 进入/home/up/openssl-1.0.2o

4. 执行./config no-asm -fPIC shared  --prefix=/home/up/openssl-1.0.2o/arm-openssl --openssldir=/home/up/openssl-1.0.2o/arm-openssl --cross-compile-prefix=arm-hisiv400-linux- 

5. make

6. make install

编译时遇到的问题:

arm-hisiv400-linux-gcc: error: unrecognized command line option '-m64'

解决方法:

由于海思的交叉编译工具为32位的,因此需要将该参数去掉,进入Makefile,将有-m64的参数全部删去

 

编译libevent

1. 下载libevent源码,我这里的为libevent-2.1.8-stable.tar.gz

2. 解压到指定目录,tar xzf libevent-2.1.8-stable.tar.gz -C /home/up

3. 进入/home/up/libevent-2.1.8-stable

4. 执行./configure --prefix=/home/up/libevent-2.1.8-stable/arm_libevent --host=arm-hisiv400-linux CC=arm-hisiv400-linux-gcc1. CXX=arm-hisiv400-linux-g++

5. make

6. make install

遇到的问题:

问题1:

bufferevent_openssl.c:66:25: fatal error: openssl/bio.h: No such file or directory

 #include <openssl/bio.h>

解决方法:

对于此类没有头文件的出错,可以到刚才编译过的openssl库中将对应得头文件拷贝到 include/openssl下

问题2:

/opt/hisi-linux/x86-arm/arm-hisiv400-linux/bin/../lib/gcc/arm-hisiv400-linux-gnueabi/4.8.3/../../../../arm-hisiv400-linux-gnueabi/bin/ld: cannot find -lssl

/opt/hisi-linux/x86-arm/arm-hisiv400-linux/bin/../lib/gcc/arm-hisiv400-linux-gnueabi/4.8.3/../../../../arm-hisiv400-linux-gnueabi/bin/ld: cannot find -lcrypto

解决方法:

从刚才编译的openssl获取动态库,放到hisiv400的lib下

sudo cp ~/openssl-1.0.2o/arm-openssl/lib/*so* /opt/hisi-linux/x86-arm/arm-hisiv400-linux/target/lib -d 

 

 

编译boost

1. 下载boost源码,我这里的为boost_1_67_0.tar.gz

2. 解压到指定目录,tar xzf boost_1_67_0.tar.gz -C /home/up

3. 进入/home/up/boost_1_67_0

4. 执行./bootstrap.sh

5. 

   修改project-config.jam:

   注意:上面的空格必须要有。

   if ! gcc in [ feature.values <toolset> ]

   {

       using gcc : arm : arm-hisiv400-linux-gcc ;

   }

   # These settings are equivivalent to corresponding command-line

    # options.

   option.set prefix : /home/up/boost_1_67_0/_install ;

   option.set exec-prefix : /home/up/boost_1_67_0/_install ;

   option.set libdir : /home/up/boost_1_67_0/_install/lib ;

   option.set includedir : /home/up/boost_1_67_0/_install/include ;

6. ./bjam

7. ./bjam install

 

 

编译Thrfit:

1. 下载thrift源码,我这里的为thrift-0.11.0.tar.gz

2. 解压到指定目录,tar xzf thrift-0.11.0.tar.gz -C /home/up

3. 进入/home/up/thrift-0.11.0

4. 由于编译选项较多,因此写了个编译脚本

#! /bin/bash

# openssl安装目录

OPENSSL_DIR="/home/su/code/openssl-1.0.2o/_install"

# boost安装目录

export BOOST_ROOT="/home/su/code/boost_1_67_0/_install/"

# libevent安装目录

export LIBEVENT_DIR="/mnt/hgfs/code/OpenSource/libevent-2.1.8-stable/_install_3536/"


TOOLCHAIN=arm-hisiv400-linux-

export CC=${TOOLCHAIN}gcc

export CXX=${TOOLCHAIN}g++

export CPPFLAGS="-I$OPENSSL_DIR/include -march=armv7-a"

export LDFLAGS="-L$OPENSSL_DIR/lib"


./configure --prefix=$(pwd)/_install_3536 \

    --host=i686 --target=arm \

    --disable-tests \

    --disable-shared \

    --disable-tutorial \

    --with-cpp \

    --without-python \

    --without-java \

    --without-lua \

    --without-perl \

    --with-c_glib \

    --enable-static \

    --with-boost=${BOOST_ROOT} \

    --with-libevent=${LIBEVENT_DIR}

5. make

6. make install

遇到的问题:

/opt/hisi-linux/x86-arm/arm-hisiv400-linux/arm-hisiv400-linux-gnueabi/include/c++/4.8.3/cstdlib:140:11: error: ‘::malloc’ has not been declared

   using ::malloc;

           ^

/opt/hisi-linux/x86-arm/arm-hisiv400-linux/arm-hisiv400-linux-gnueabi/include/c++/4.8.3/cstdlib:153:11: error: ‘::realloc’ has not been declared

   using ::realloc;

解决方法:

成功执行configure后(在未执行configure之前找不到下列两行),修改对应的编译文件目录下面的config.h,将文件中的如下两行注释掉:

#define malloc rpl_malloc

#define realloc rpl_realloc
 

 

 

  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值