海思交叉编译一些工具和库(iperf3/openssl/libevent/boost/thrift等)

包括编译iperf3、thrift、openssll、ntp等。

编译strace-5.11

CC=aarch64-linux-gnu-gcc CXX=aarch64-linux-gnu-g++ ./configure --host=arm --prefix=`pwd`/_install__

一、为Hi3559AV100编译iperf3时

./configure --host=aarch64-himix100-linux --prefix=`pwd`/install

出现如下报错:
/opt/hisi-linux/x86-arm/aarch64-himix100-linux/host_bin/../lib/gcc/aarch64-linux-gnu/6.3.0/../../../../aarch64-linux-gnu/bin/ld: cannot find -lssl
/opt/hisi-linux/x86-arm/aarch64-himix100-linux/host_bin/../lib/gcc/aarch64-linux-gnu/6.3.0/../../../../aarch64-linux-gnu/bin/ld: cannot find -lcrypto

二、下载openssl源码openssl-1.0.2t.tar.gz

./config no-asm -fPIC no-shared --prefix=`pwd`/__install__ --openssldir=`pwd`/__install__ --cross-compile-prefix=aarch64-himix100-linux-
然后修改Makefile,删除“-m64”,如果编译出动态库(*.so)则使用shared

最后,重新编译iperf3,指定openssl库的路径,并静态编译iperf3:

make "LDFLAGS=-L/home/default/work/other/openssl-1.0.2o/__install__/lib" "CFLAGS=-static" "CXXFLAGS=-static"

参考:https://blog.csdn.net/wangzhen_csdn/article/details/88045761

https://blog.csdn.net/edw200/article/details/70502522

 

三、下面是Hi3536平台编译thritf

A,编译openssl:

这里使用更新的openssl-1.0.2u,编译方法参考上面。

B,编译libevent
1. 下载libevent源码,我这里的为libevent-2.1.11-stable.tar.gz

执行./configure --prefix=`pwd`/_install__ --host=arm-hisiv400-linux

2. make

3. make install

遇到的问题:

问题1:

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

 #include <openssl/bio.h>

问题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库路径为/home/default/work/other/thrift_depend_lib/openssl-1.0.2o,则指定库路径:

./configure CPPFLAGS="-I/home/default/work/other/thrift_depend_lib/openssl-1.0.2o/include" LDFLAGS="-L/home/default/work/other/thrift_depend_lib/openssl-1.0.2o/lib -lssl -lcrypto" --prefix=/home/default/work/other/thrift_depend_lib/libevent-2.1.8-stable --host=arm-hisiv400-linux

C,编译boost
1. 下载boost源码,这里最新的boost_1_73_0.tar.gz

2. 运行./bootstrap.sh --show-libraries查看有哪些模块,按需编译,下面是其中一个例子:

./bootstrap.sh --without-libraries=container,context,exception,stacktrace,type_erasure,headers,filesystem,locale,chrono,contract,fiber,graph,graph_parallel,iostreams,log,math,mpi,nowide,python,program_options,random,test,wave --without-icu --prefix=`pwd`/__install__

#保留一些常用的模块:“atomic date_time regex serialization system thread timer coroutine”等

3. 修改project-config.jam加入海思的交叉编译工具链:

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

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

   {

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

   }

4. 运行./b2 install进行编译

D,编译Thrfit:
1. 下载thrift源码,这里用最新的thrift-0.13.0.tar.gz

2. cd thrift-0.13.0

3.

#! /bin/bash
# openssl安装目录
OPENSSL_DIR="/home/default/work/other/openssl-1.0.2u/__install__"
# boost安装目录
export BOOST_ROOT="/home/default/work/other/boost_1_73_0/__install__"
# libevent安装目录
export LIBEVENT_DIR="/home/default/work/other/libevent-2.1.11-stable/__install__"
TOOLCHAIN=arm-hisiv400-linux-
export CC=${TOOLCHAIN}gcc
export CXX=${TOOLCHAIN}g++
export CPPFLAGS="-I$OPENSSL_DIR/include -march=armv7-a -mfloat-abi=softfp -mfpu=neon-vfpv4 -mno-unaligned-access -fno-aggressive-loop-optimizations"
export LDFLAGS="-L$OPENSSL_DIR/lib"
./configure --prefix=$(pwd)/_install_3536 \
--host=i686 --target=arm \
--disable-tests \
--disable-shared \
--disable-tutorial \
--with-cpp \
--without-py3 \
--without-python \
--without-java \
--without-lua \
--without-perl \
--without-c_glib \
--enable-static \
--with-boost=${BOOST_ROOT} \
--with-libevent=${LIBEVENT_DIR}

配置如下:

thrift 0.13.0

Building ActionScript3 Library : no
Building C (GLib) Library .... : no
Building C# (Mono) Library ... : no
Building C++ Library ......... : yes
Building Common Lisp Library.. : no
Building D Library ........... : no
Building Dart Library ........ : no
Building dotnetcore Library .. : no
Building .NET Standard Library : no
Building Erlang Library ...... : no
Building Go Library .......... : no
Building Haskell Library ..... : no
Building Haxe Library ........ : no
Building Java Library ........ : no
Building Lua Library ......... : no
Building NodeJS Library ...... : no
Building Perl Library ........ : no
Building PHP Library ......... : no
Building Python Library ...... : no
Building Py3 Library ......... : no
Building Ruby Library ........ : no
Building Rust Library ........ : no
Building Swift Library ....... : no

C++ Library:
   C++ compiler .............. : arm-hisiv400-linux-g++ -std=c++11
   Build TZlibTransport ...... : yes
   Build TNonblockingServer .. : yes
   Build TQTcpServer (Qt5) ... : no
   C++ compiler version ...... : arm-hisiv400-linux-g++ (Hisilicon_v400) 4.8.3 20131202 (prerelease)

4,make && make install

出现错误:

a).

/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;

需要修改./lib/cpp/src/thrift/config.h和./config.h两个文件,因为make install安装后用的是.config.h这个文件

注释掉如下两行:
#define malloc rpl_malloc
#define realloc rpl_realloc

但仍然出现编译错误:

b).

In file included from ./src/thrift/protocol/TCompactProtocol.h:264:0,
                 from src/thrift/transport/THeaderTransport.cpp:24:
./src/thrift/protocol/TCompactProtocol.tcc:34:3: error: #error "Unable to determine the behavior of a signed right shift"
 # error "Unable to determine the behavior of a signed right shift"
   ^
In file included from ./src/thrift/protocol/TCompactProtocol.h:264:0,
                 from src/thrift/protocol/THeaderProtocol.cpp:23:
./src/thrift/protocol/TCompactProtocol.tcc:34:3: error: #error "Unable to determine the behavior of a signed right shift"
 # error "Unable to determine the behavior of a signed right shift"
   ^

暂时没有解决,不知什么回事!

可尝试修改./lib/cpp/src/thrift/config.h和./config.h两个文件,加入如下宏定义:

#define SIGNED_RIGHT_SHIFT_IS 1
#define ARITHMETIC_RIGHT_SHIFT 1

或者先在pc上编译,然后参考pc上用的config.h

参考:https://blog.csdn.net/A707471534/article/details/102329482

参考:https://www.cnblogs.com/ay-a/p/10459065.html

 

四、编译NTP对时服务器ntp-4.2.8p15:

编译ntp前先按照上述方法编译openssl-1.0.2o依赖,然后指定 绝对路径:

./configure --prefix=`pwd`/__hi3559__ --host=arm-linux CC=aarch64-himix100-linux-gcc --with-yielding-select=no --with-openssl-incdir=xxxxx/__hi3559_install__/include --with-openssl-libdir=xxxx/__hi3559_install__/lib --enable-local-libevent

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值