Migrate project using 3rd libraries to SDX by Cross Compiling---cross compile PCL library

Platform: Ubuntu16.04+cmake3.5+xilinx sdsoc2017.4 (note:sdsoc need at least ubuntu16.03)
3rd libraries: PCL1.8.1,Boost1.67,Flann1.8.4,eigen. All are source code from official website.(Embedded system doesn’t need VTK library)
Target platform: Zed board;ARM;Cortex A9

Write forward: I have spent a lot of time on cross compiling these libraries on windows but failed.So recommend Ubuntu.Besides,do after read whole the article to avoid ineffectual work.

1: From this article https://blog.csdn.net/sun_28/article/details/52760463 we can know the feasibility of cross compiling library on Ubuntu.And later this article also helps me on how to use cmake-gui cross compile library.

2: Config cross compile toolchain. Main reference article:
https://blog.csdn.net/hebbely/article/details/53992805
我们可以通过源代码编译安装交叉编译链构建交叉编译环境,但是这个过程比较繁琐容易出错,其实在安装Vivado SDK时就已经安装好了交叉编译链,我们只需要进行一些简单的配置。打开~/.bashrc文件在文件结尾输入以下内容

export PATH=$PATH:/media/wolfhao/Software/Xilinx/SDK/2017.4/gnu/aarch32/lin/gcc-arm-linux-gnueabi/bin
export CROSS_COMPILE=arm-linux-gnueabihf- 

当上面的步骤结束后重新打开一个终端使刚才的配置生效,通过如下命令进行验证:

$ arm-linux-gnueabihf-gcc -v 

如果成功打印交叉编译器版本信息,证明成功设置系统环境。

More information about XIlinx cross compile toolchain:
https://www.xilinx.com/html_docs/xilinx2018_2/sdaccel_doc/compiler-toolchain-support-gdz1504034401132.html

3: Install dependency libraries and related tools. Main reference article:
ubuntu14.04 编译源码安装PCL1.8
PCL official tutorial

From this step you can compile the PCL library by host compiler and use PCL on host platform.If you only want to cross compile,ignore this step.
Suggestion: you can search tutorials for your platform version.My first ubuntu version is 14.04.

4: Cross compile boost,eigen,flann and PCL from source code
cross compile eigen and flann is easy, just open cmake-gui and choose specify options for cross compile ,
config the cross compile toolchain , target system and processor is ok.

cross compile options in cmake

As for cross compiling boost library, refer to article:
https://blog.csdn.net/GW569453350game/article/details/49153855
Remember to modify the cross compiler and version of boost.What’s more, remember to choose the compile command with Boost.Coroutine.

如果需要编译 Boost.Coroutine 和 Boost.Context (For Arm):
./bjam install toolset=gcc-arm architecture=arm address-model=32 abi=aapcs binary-format=elf --disable-sNO_ZLIB=1 -sNO_BZIP2=1 --without-python --prefix=/path/to/install

If not,there will be some errors when building project in SDX.
Tips: For some special library which can’t install by “sudo cmake install” , maybe cmake find_package can’t find the library.As a result , you need to add the library to cmake related modules.I spent three days on this problem for cannot find cross compiled boost library.

5: Cross compile PCL library
If all the libraries mentioned above were cross compiled successfully, cross compile PCL library will be a easy task.Just open the CMakeLists.txt in pcl folder and annotate anything about VTK.Any problem see FAQ.

6: Build project in SDX
All the above work are prepared for the building step in SDX.After adding the include files and library files to the project,there may be some warnings about pcl library.
For example:

warning: ../lib/libpcl_features.so, needed by
/usr/arm_build/pcl1.8/lib/libpcl_keypoints.so, not found (try using -rpath or -rpath-link)

This is a link problem.Right click your project and click “C/C++ Building Settings” ,
Add “-Wl,-rpath-link=${SYSROOT}/usr/arm_build/pcl1.8/lib“[do not need “”]
in C/C++ Build–>Settings–>SDS++ linker–>Miscellaneous–>Link Flags.
Then the warnings will be solved.

FAQ(Conclude the problems)

  • Cross compile toolchain is essential for Cross compile.If you want to use the library in SDX or Xilinx software,you’d better use Xilinx’s cross compile toolchain which could be config by step:Config cross cimpile toolchain.
  • Boost library could be used on different platforms and Take care of it.If you want to find boost library by cmake,never forget to add
SET(Boost_ADDITIONAL_VERSIONS "1.67" "1.67.0")
SET(BOOST_ROOT "/uar/arm_build/boost")

to /usr/share/cmake-3.5/Modules/FindBoost.cmake.If not,cmake won’t find your boost installed from source code.
- There may comes the problem that “can’t found command arm-linux-gnueabihf-gcc” when using “sudo ./bjam …”.You can find the answer from this article. https://blog.csdn.net/mao0514/article/details/10132195

$ sudo –s  
$ export PATH=$PATH:/media/wolfhao/Software/Xilinx/SDK/2017.4/gnu/aarch32/lin/gcc-arm-linux-gnueabi/bin
  • A strange error when make PCL:
    recipe for target ‘common/CMakeFiles/pcl_common.dir/all’ failed====>My error comes from that I haven’t cross compiled boost library sucessfully.
  • I believe that most of my problems have been faced and solved by others,what I need to do is to find it.

My english is poor so please forgive my syntax error.

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值