PCL1.9.0的交叉编译过程

环境

系统Ubuntu18.04
Host架构x86
Target架构ARMv8 64bit
PCL版本1.9.0
Boost版本1.68.0
Eigen版本3.4.0
Flann版本1.9.2
Lz4版本1.9.4

任务需求:在x86架构的Ubuntu18.04的虚拟机中交叉编译PCL源码,以能在ARMv8 64位系统上运行。

1、下载以上对应版本的源码,并解压
2、在解压后的pcl-1.9.0目录中新建build目录
3、打开Cmake,按下图根据自己的需求配置交叉编译选项,因为我没有显示需求,所以不需要OpenGL和VTK
在这里插入图片描述
4、其他的部分都比较顺利,主要问题出在Boost库上,因为PCL需要Boost,cmake时会提示无法找到Boost的错误,修改pcl工程下的文件,如图所示
在这里插入图片描述
在pcl_find_boost.cmake文件开头加入以下内容,并保存

set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_MULTITHREADED ON)
set(Boost_USE_STATIC OFF)
add_definitions(-DBoost_USE_STATIC_LIBS=ON)
set(Boost_INCLUDE_DIR /usr/local/include/)
set(Boost_LIBRARY_DIR /usr/local/lib/)

5、第三方库重点是Boost库的编译,流程如下

  1. 执行./bootstrap.sh文件
./bootstrap.sh --with-libraries=system,filesystem,thread,date_time,iostreams --with-toolset=gcc #system,filesystem,thread,date_time,iostreams这些库是PCL所必须的,根据需求填写
  1. 修改project-config.jam文件在这里插入图片描述
    将原有的改为(根据自己的交叉编译工具路径来定)
    using gcc : arm : /usr/bin/aarch64-linux-gnu-gcc ; 
  1. 修改gcc.jam文件在这里插入图片描述
    增加如下一行:
    compile-link-flags <link>static/<target-os>$(non-windows) : -fPIC ;

此步骤的主要目的是打开-fPIC,避免PCL在编译时找不到boost库的.a文件

  1. 进行编译并安装boost
sudo ./b2 cxxflags=-fPIC cflags=-fPIC -a install

6、PCL在编译中的Eigen错误解决
如果出现以下错误的话:
在这里插入图片描述

应修改文件:
在这里插入图片描述

按如下方式替换:

/*
  Eigen::Vector3f view = camera_pose_.block (0, 0, 3, 1);    // view vector for the camera  - first column of the rotation matrix
  Eigen::Vector3f up = camera_pose_.block (0, 1, 3, 1);      // up vector for the camera    - second column of the rotation matrix
  Eigen::Vector3f right = camera_pose_.block (0, 2, 3, 1);   // right vector for the camera - third column of the rotation matrix
  Eigen::Vector3f T = camera_pose_.block (0, 3, 3, 1);       // The (X, Y, Z) position of the camera w.r.t origin
*/

  Eigen::Vector3f view = camera_pose_.block<3, 1> (0, 0);    // view vector for the camera  - first column of the rotation matrix
  Eigen::Vector3f up = camera_pose_.block<3, 1> (0, 1);      // up vector for the camera    - second column of the rotation matrix
  Eigen::Vector3f right = camera_pose_.block<3, 1> (0, 2);   // right vector for the camera - third column of the rotation matrix
  Eigen::Vector3f T = camera_pose_.block<3, 1> (0, 3);       // The (X, Y, Z) position of the camera w.r.t origin
/*
  pl_f.block (0, 0, 3, 1).matrix () = (fp_bl - fp_br).cross (fp_tr - fp_br);   // Far plane equation - cross product of the 
  pl_f (3) = -fp_c.dot (pl_f.block (0, 0, 3, 1));                    // perpendicular edges of the far plane

  pl_n.block (0, 0, 3, 1).matrix () = (np_tr - np_br).cross (np_bl - np_br);   // Near plane equation - cross product of the 
  pl_n (3) = -np_c.dot (pl_n.block (0, 0, 3, 1));                    // perpendicular edges of the far plane
*/
  pl_f.block<3, 1> (0, 0).matrix () = (fp_bl - fp_br).cross (fp_tr - fp_br);   // Far plane equation - cross product of the 
  pl_f (3) = -fp_c.dot (pl_f.block<3, 1> (0, 0));                    // perpendicular edges of the far plane

  pl_n.block<3, 1> (0, 0).matrix () = (np_tr - np_br).cross (np_bl - np_br);   // Near plane equation - cross product of the 
  pl_n (3) = -np_c.dot (pl_n.block<3, 1> (0, 0));                    // perpendicular edges of the far plane
/*
  pl_r.block (0, 0, 3, 1).matrix () = b.cross (c);
  pl_l.block (0, 0, 3, 1).matrix () = d.cross (a);
  pl_t.block (0, 0, 3, 1).matrix () = c.cross (d);
  pl_b.block (0, 0, 3, 1).matrix () = a.cross (b);

  pl_r (3) = -T.dot (pl_r.block (0, 0, 3, 1));
  pl_l (3) = -T.dot (pl_l.block (0, 0, 3, 1));
  pl_t (3) = -T.dot (pl_t.block (0, 0, 3, 1));
  pl_b (3) = -T.dot (pl_b.block (0, 0, 3, 1));
*/
  pl_r.block<3, 1> (0, 0).matrix () = b.cross (c);
  pl_l.block<3, 1> (0, 0).matrix () = d.cross (a);
  pl_t.block<3, 1> (0, 0).matrix () = c.cross (d);
  pl_b.block<3, 1> (0, 0).matrix () = a.cross (b);

  pl_r (3) = -T.dot (pl_r.block<3, 1> (0, 0));
  pl_l (3) = -T.dot (pl_l.block<3, 1> (0, 0));
  pl_t (3) = -T.dot (pl_t.block<3, 1> (0, 0));
  pl_b (3) = -T.dot (pl_b.block<3, 1> (0, 0));

7、编译过程中的Lz4库的错误
在这里插入图片描述
在如图所示目录下打开link.txt,加入 -llz4
在这里插入图片描述
8、根据电脑内存情况来
执行make -j2,直到编译完成

评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值