用了pcl的地方, 程序直接崩溃 挂掉

在程序里用了

    pcl::PassThrough<pcl::PointXYZ> pass;
    pass.setInputCloud(cloud);
    pass.setFilterFieldName("z");
    pass.setFilterLimits(-1.2, 0);//保留或过滤z轴方向-1.2到0
    pass.filter(*cloud_filtered);

这样一段代码,在ubuntu16.04的系统上运行没有问题,但是把程序放到ubuntu14.04上,能编译通过,但是一启动程序,程序直接挂掉,后面检查发现,在14.04上要这样实例化:pcl::PassThrough<pcl::PointXYZ>::Ptr pass ;程序才不会挂掉。

把pcl::PassThrough<pcl::PointXYZ>::Ptr pass ; 放在16.04上运行,程序又挂了,改成 pcl::PassThrough<pcl::PointXYZ> pass;就好了。

不懂原因。

 

gdb调试的时候发现错误:

0x00007ffff0266340 in boost::math::lanczos::lanczos_initializer<boost::math::lanczos::lanczos17m64, long double>::init::init() ()    from /usr/lib/libpcl_features.so.1.7

在网上发现了问题的其他解决方法。

因为在Cmake中使用了

SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -std=gnu++0x")

这个是和boost是有冲突的,所以直接就不能使用了,解决方案就是尽量不使用c++11中新的特性。

在cmakelists里添加命令:

set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O1")。

或者如果要用C+11编译,则将程序该为release模式就可以跑了。

 

引用如下

To resolve this issue, you need to go a bit deeper. To my knowledge, it is caused by the differing boost implementations when compiling with c++11 and something else. As the PCl is not compiled with -std=c++11 option, it will contain different boost headers compared to rgbdslam. This results in segmentation fault on the initialization of boost.

To correct this, you need to compile PCL from their git repo (this change might be needed PointCloudLibrary/pcl#980). One way to make PCL compile with the c++11 option is to add this to the CMakeLists.txt: SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")

When you have the PCL compiled, you need to make install, and change CMakeLists.txt on rgbdslam to use these libraries, this can be done by changing the line: find_package(PCL 1.7 REQUIRED COMPONENTS common io) to find_package(PCL 1.8 REQUIRED COMPONENTS common io)
 

 

问题与ros无关,是因为pcl1.7不支持c++11新特性。

参考:

https://stackoverflow.com/questions/26346690/debug-seg-fault-in-boostmathlanczos-with-libpcl-surface

https://blog.csdn.net/u014610460/article/details/85223960

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值