【工程配置】基于arm-linux-gnueabihf-g++ build boost C++ library

基于arm-linux-gnueabihf-g++ build boost C++ library

1.前述

近期由于工作需要,要自己在板子上搭建Socket.io-client-cpp,首先需要Build boost c++ library 然后Build Socket.io-client-cpp Library,最终可Build Socket.io-client-cpp 实例。本文主要是针对搭建过程中的踩坑记录。

2.Build boost c++ library

首先,基于g++编译boost c++ library
wget https://www.boost.org/users/history/version_1_65_0.html 并解压

Run ./bootstrap.sh
#build using default gcc
Run ./b2 install
#文件(.a.so)会存在./boost_1_65_0/stage/lib中

然后using toolchain arm-linux-gnueabihf-g++ to build
需要手动修改project-config.jam文件中 using gcc ;
改为:

using gcc : arm : arm-linux-gnueabihf-g++ ;
#添加环境路径
export PATH=$PATH:/opt/gcc-sigmastar-9.1.0-2019.11-x86_64_arm-linux-gnueabihf(toolchain 的文件名)/bin
# build
./b2 -toolset=arm-linux-gnueabihf-g++ --stagedir=./stage-arm-gnueabihf-g++

报错如下:

...failed gcc.compile.c++ bin.v2/libs/python/build/gcc-arm/release/threading-multi/converter/type_id.o...
gcc.compile.c++ bin.v2/libs/python/build/gcc-arm/release/threading-multi/object/enum.o
In file included from ./boost/python/detail/wrap_python.hpp:50:0,
                 from ./boost/python/detail/prefix.hpp:13,
                 from ./boost/python/object_core.hpp:10,
                 from ./boost/python/object/enum_base.hpp:8,
                 from libs/python/src/object/enum.cpp:6:
/usr/include/python2.7/pyconfig.h:24:12: fatal error: arm-linux-gnueabihf/python2.7/pyconfig.h: No such file or directory
 #  include <arm-linux-gnueabihf/python2.7/pyconfig.h>
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.



...failed gcc.compile.c++ bin.v2/libs/python/build/gcc-arm/release/threading-multi/numpy/ufunc.o...
...skipped <pbin.v2/libs/python/build/gcc-arm/release/threading-multi>libboost_numpy.so.1.65.0 for lack of <pbin.v2/libs/python/build/gcc-arm/release/threading-multi>numpy/dtype.o...
...skipped <pstage-arm-gnueabihf-g++/lib>libboost_numpy.so.1.65.0 for lack of <pbin.v2/libs/python/build/gcc-arm/release/threading-multi>libboost_numpy.so.1.65.0...
...skipped <pstage-arm-gnueabihf-g++/lib>libboost_numpy.so for lack of <pstage-arm-gnueabihf-g++/lib>libboost_numpy.so.1.65.0...
...failed updating 66 targets...
...skipped 12 targets...

主要原因为/usr/include/python2.7/pyconfig.h中会引用arm-linux-gnueabihf下编译好的pyconfig.h文件,找不到arm-linux-gnueabihf/python2.7/pyconfig.h
解决方法:
Debian python-dev软件包中下载对应python2.7版本的armel.deb文件(本机版本为2.7.15rc1)并解压到include中。

#下载文件
wget http://ports.ubuntu.com/pool/main/p/python2.7/libpython2.7-dev_2.7.15~rc1-1_armhf.deb
#解压
dpkg -x libpython2.7-dev_2.7.15~rc1-1_armhf.deb libpython2.7-dev_2.7.15~rc1-1_armhf_extracted
#复制到指定位置
sudo cp -r libpython2.7-dev_2.7.15~rc1-1_armhf_extracted/usr/include/arm-linux-gnueabihf/ /usr/local/include/

修改/usr/include/python2.7/pyconfig.h中对arm-linux-gnueabihf的引用:

cd /sur/include/python2.7
sudo vim pyconfig.h

 <arm-linux-gnueabihf/python2.7/pyconfig.h>
#修改为: 
 </usr/local/include/arm-linux-gnueabihf/python2.7/pyconfig.h>
 
 #最终于boost文件夹运行g++ build
 ./b2 -toolset=arm-linux-gnueabihf-g++ --stagedir=./stage-arm-gnueabihf-g++

完美解决

...updated 78 targets...


The Boost C++ Libraries were successfully built!

The following directory should be added to compiler include paths:

    /home/damon/Lucien/D700/boost_1_65_0

The following directory should be added to linker library paths:

    /home/damon/Lucien/D700/boost_1_65_0/stage-arm-gnueabihf-g++/lib

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值