I am attempting to run the following in C++:
#include <pcl_ros/point_cloud.h>
#include "pcl/pcl_base.h"
#include "pcl/PointIndices.h"
#include "pcl/conversions.h"
#include <pcl/kdtree/kdtree_flann.h>
#include <pcl/filters/extract_indices.h>
#include <pcl/filters/voxel_grid.h>
using namespace std;
using namespace pcl;
void myFunction() {
...
ExtractIndices<PointXYZ> rangefilter;
...
}
int main() {
cout << "Hello" << endl;
}
The code compiles, but I get a segmentation fault as soon as I run it; the cout statement isn't executed. Notice I don't actually even call myFunction() in main. The only error message is
Segmentation fault (core dumped)
When I comment out the ExtractIndices line in myFunction, the problem goes away and the code runs fine:
// ExtractIndices<PointXYZ> rangefilter;
I am running this on Ubuntu with ROS and compiling it with catkin_make, if that helps.
I'd really appreciate some help debugging this, as I've been stuck on this problem for a while. Thanks for reading!