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.
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)
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
My english is poor so please forgive my syntax error.