Pcl: catkin_make with pcl error

Created on 25 May 2019  Â·  12Comments  Â·  Source: PointCloudLibrary/pcl

I use ubuntu 16.04 and pcl version is pcl-1.9,
when I use catkin_make with my ros package,
there show error:

In file included from /usr/local/include/pcl-1.9/pcl/pcl_macros.h:39:0,
from /usr/local/include/pcl-1.9/pcl/PCLHeader.h:10,
from /usr/local/include/pcl-1.9/pcl/point_cloud.h:47,
/usr/local/include/pcl-1.9/pcl/pcl_config.h:7:4: error: #error PCL requires C++14 or above
#error PCL requires C++14 or above
^
In file included from /usr/local/include/pcl-1.9/pcl/console/print.h:44:0,
from /usr/local/include/pcl-1.9/pcl/conversions.h:53,
from /opt/ros/kinetic/include/pcl_conversions/pcl_conversions.h:44,
/usr/local/include/pcl-1.9/pcl/pcl_config.h:7:4: error: #error PCL requires C++14 or above
#error PCL requires C++14 or above
In file included from /usr/local/include/pcl-1.9/pcl/io/pcd_io.h:43:0,
from /opt/ros/kinetic/include/pcl_conversions/pcl_conversions.h:70,
/usr/local/include/pcl-1.9/pcl/io/file_io.h:235:8: error: ‘enable_if_t’ in namespace ‘std’ does not name a template type
std::enable_if_t::value>
/usr/local/include/pcl-1.9/pcl/io/file_io.h:266:18: error: expected initializer before ‘<’ token
copyValueString (const pcl::PCLPointCloud2 &cloud,
/usr/local/include/pcl-1.9/pcl/io/file_io.h:280:18: error: expected initializer before ‘<’ token
copyValueString (const pcl::PCLPointCloud2 &cloud,
^
/usr/local/include/pcl-1.9/pcl/io/file_io.h:304:8: error: ‘enable_if_t’ in namespace ‘std’ does not name a template type
std::enable_if_t::value, bool>
^
/usr/local/include/pcl-1.9/pcl/io/file_io.h:317:8: error: ‘enable_if_t’ in namespace ‘std’ does not name a template type
std::enable_if_t::value, bool>

my cmakelist as follow:

find_package(PCL 1.9 REQUIRED)

catkin_package(
INCLUDE_DIRS
${EIGEN3_INCLUDE_DIR}
${PCL_INCLUDE_DIRS}
CATKIN_DEPENDS
roscpp
)

include_directories(
include ${catkin_INCLUDE_DIRS}
include
${catkin_INCLUDE_DIRS}
${EIGEN3_INCLUDE_DIR}
${PCL_INCLUDE_DIRS}
)

my cpp file as follow:

include

include

include

include

include

int main (int argc, char **argv)
{
ros::init (argc, argv, "loadpcd");
ros::NodeHandle nh;
ros::Publisher pcl_pub = nh.advertise ("pcl_load", 10);
pcl::PointCloud cloud;
sensor_msgs::PointCloud2 output;
pcl::io::loadPCDFile ("/home/0-sim_bag/loam.pcd", cloud);
//Convert the cloud to ROS message
pcl::toROSMsg(cloud, output);
output.header.frame_id = "odom";//this has been done in order to be able to visualize our PointCloud2 message on the RViz visualizer
ros::Rate loop_rate(1);
while (ros::ok())
{
pcl_pub.publish(output);
ros::spinOnce();
loop_rate.sleep();
}
return 0;
}

So can you tell me how to solve this problem ? Thank you !

question cmake

Most helpful comment

Add these two line at the top of your CMake file after defining the project. Hopefully it will compile.

# Set target C++ standard and required compiler features
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

Alternatively, use pcl 1.9.1 instead of the development version from GitHub.

All 12 comments

Add these two line at the top of your CMake file after defining the project. Hopefully it will compile.

# Set target C++ standard and required compiler features
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

Alternatively, use pcl 1.9.1 instead of the development version from GitHub.

Yes, I try this way yesterday, but there stiil have error in catkin_make, just as follow:

CMakeFiles/loadpcd. Dir/SRC/loadpcd. CPP. O: in function 'photo: : PCDReader: : PCDReader ()' :
Loadpcd.cpp :(.text._zn3pcl9pcdreaderc2ev [_ZN3pcl9PCDReaderC5Ev]+0x19) : undefined reference to 'vtable for PCL ::PCDReader'
CMakeFiles/loadpcd. Dir/SRC/loadpcd. CPP. O: in function 'photo: : PCDReader: : ~ PCDReader ()' :
Loadpcd.cpp :(.text._zn3pcl9pcdreaderd2ev [_ZN3pcl9PCDReaderD5Ev]+0xd) : undefined reference to 'vtable for PCL ::PCDReader'
CMakeFiles/loadpcd. Dir/SRC/loadpcd. CPP. O: in function 'void PCLS: : detail: : FieldMapper < photo: : PointXYZ > : : operator () < photo: : fields: : x > ()' :
Loadpcd. CPP: (. Text. _ZN3pcl6detail11FieldMapperINS_8PointXYZEEclINS_6fields1xEEEvv [_ZN3pcl6detail11FieldMapperINS_8PointXYZEEclINS_6fields1xEEEvv] + 0 x1b2) : Print (PCL ::console::print(PCL ::console::VERBOSITY_LEVEL, char const... An undefined reference
CMakeFiles/loadpcd. Dir/SRC/loadpcd. CPP. O: in function 'void PCLS: : detail: : FieldMapper < photo: : PointXYZ > : : operator () < photo: : fields: : y > ()' :
Loadpcd. CPP: (. Text. _ZN3pcl6detail11FieldMapperINS_8PointXYZEEclINS_6fields1yEEEvv [_ZN3pcl6detail11FieldMapperINS_8PointXYZEEclINS_6fields1yEEEvv] + 0 x1b2) : Print (PCL ::console::print(PCL ::console::VERBOSITY_LEVEL, char const
... An undefined reference
CMakeFiles/loadpcd. Dir/SRC/loadpcd. CPP. O: in function 'void PCLS: : detail: : FieldMapper < photo: : PointXYZ > : : operator () < photo: : fields: : z > ()' :
Loadpcd. CPP: (. Text. _ZN3pcl6detail11FieldMapperINS_8PointXYZEEclINS_6fields1zEEEvv [_ZN3pcl6detail11FieldMapperINS_8PointXYZEEclINS_6fields1zEEEvv] + 0 x1b2) : Print (PCL ::console::print(PCL ::console::VERBOSITY_LEVEL, char const*... An undefined reference
Collect2: error: ld returned 1 exit status

In your CMake snippet I see no command linking against ${PCL_LIBRARIES}. That would cause the compile issues you're seeing here.

OK, I add this and it worked !
Thank you!

@SergioRAgostinho I have the linking commands in my CMakeLists.txt but still getting undefined reference to errors. Any inputs?

Please follow our guidelines and post such support questions on Stack Overflow. Make sure to provide more detailed information as it is virtually impossible to give any meaningful suggestions to a request like "Stuff does not work -- help!"

@taketwo Is that a joke? Stack Overflow is the worst place for quick questions. Hell I can't even answer questions because of the bullcrap points system. I have to ask questions to be able to answer? That's freaking stupid.

@SergioRAgostinho Thanks for the solution. This helped for building rtabmap.

Compared to StackOverflow, https://gitter.im/PointCloudLibrary/pcl is a good forum to get PCL related "help" @parkerlreed
:)

Hey guys could you please help me with this error.

I get this same error PCL requires c++14 or above error.
I tried adding to the CMakeLists.txt found in the sick_scan/, right below cmake_minimum_required(VERSION2.8.3) but i still face the same error.

Set target C++ standard and required compiler features

set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
Capture

Here i have attached
CMakeLists.txt
the content of my /sick_scan/CMakeLists.txt file, which is exactly the same content found in the sick_scan github page under the master branch:

I would greatly appreciate your assistance!

You're setting the standard to C++11 in your CMake file. PCL 1.10 requires C++14 as the minimum.

Hi Sergio. I actually added:
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

Right below the project(sick_scan) in my Sick_Scan/CMakeLists.txt and this change alone seemed to fix most of my issue. The compilation is almost succeeding 100%. Now I only face 2 small errors, both of which are relative the same.

Could you please assist me?
I added 2 screenshots of both of them.
Capture2
Capture3

The compiler doesn't really know how to compare between the boost::system::error_code object and the integer itself; i'm just not too familiar with boost::system.

Care to elaborate if possible?

Actually got it to compile completely, it was a simple mistake in the sick_scan-provided sick_scan_common.cpp. Changed ec == 0 to: ec.value() == boost::system::errc::success. Thank you!

Was this page helpful?
0 / 5 - 0 ratings