Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot compile on ROS Noetic (Ubuntu 20.04), because of the C++ standard is too low. #13

Open
Starrah opened this issue Apr 26, 2023 · 1 comment

Comments

@Starrah
Copy link

Starrah commented Apr 26, 2023

The code failed to compile on ROS Noetic (Ubuntu 20.04). The error is about PCL, seems like below:

/home/xxx/ws/src/rs_to_velodyne/src/rs_to_velodyne.cpp:65:1: error: ‘type’ is not a member of ‘pcl::traits::datatype<VelodynePointXYZIR, pcl::fields::y>::decomposed’ {aka ‘pcl::traits::decomposeArray<float>’}
/home/xxx/ws/src/rs_to_velodyne/src/rs_to_velodyne.cpp:65:1: error: template argument 1 is invalid
   65 | POINT_CLOUD_REGISTER_POINT_STRUCT (VelodynePointXYZIR,
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

/home/xxx/ws/src/rs_to_velodyne/src/rs_to_velodyne.cpp:65:1: error: ‘plus’ is not a member of ‘pcl::traits’
   65 | POINT_CLOUD_REGISTER_POINT_STRUCT (VelodynePointXYZIR,
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

/usr/include/pcl-1.10/pcl/point_types.h: In function ‘const pcl::IntensityGradient& pcl::common::operator-=(pcl::IntensityGradient&, const float&)’:
/usr/include/pcl-1.10/pcl/point_types.h:665:1: error: ‘minusscalar’ is not a member of ‘pcl::traits’
  665 | POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::IntensityGradient,
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

/usr/include/c++/9/bits/stl_numeric.h:166:22: error: no match for call to ‘(pcl::getFieldsList(const pcl::PCLPointCloud2&)::<lambda(const int&, const int&)>) (std::__cxx11::basic_string<char>&, const pcl::PCLPointField&)’
  166 |  __init = __binary_op(_GLIBCXX_MOVE_IF_20(__init), *__first);
      |           ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~

This is because the C++ standard version specified in CMakeLists.txt is C++11, which is too low to compile on Noetic's g++ compiler.

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -O3")

Upgrade the C++ standard version to C++14 can solve the problem. Just change the line above into:
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -O3")

In my machine (ROS Noetic, Ubuntu 20.04, amd64), this can resolve the problem. (Note that you should clean the build (rm -rf build/ devel/) between making the change and running catkin_make again.)

However, I don't know whether this change will make the code fail to compile on earlier ROS distributions (Kinetic 16.04, etc).
So I'm hesitating raising a PR, instead just raise this issue as a reminder to Noetic users. If we make sure this will not introduce bug on earlier distributions, we may consider merge the change into master.

Besides, I also suggest @HViktorTsoi to add some reminder sentences on the README.md, linking to this issue, to remind other Noetic users.

@corporationsd
Copy link

(您好,我看到您是在noetic版本上运行的[rs_to_velodyne],由于我也是在noetic版本上进行的,但我在编译的过程中有些问题(警告),我截取了部分如下:)
Hello, I noticed that you are running [rs_to_velodyne] on the noetic version. As I was also running on the noetic version, there were some issues (warnings) during the compilation process. I have taken a screenshot as follows:
usr/include/pcl-1.10/pcl/pcl_macros.h:92:9: note: declared here

92 | using uint8_t [[deprecated("use std::uint8_t instead of pcl::uint8_t")]] = std::uint8_t;
| ^~~~~~~
/opt/ros/noetic/include/ros/console.h:575:35: note: in expansion of macro ‘ROS_LOG_COND’
575 | #define ROS_LOG(level, name, ...) ROS_LOG_COND(true, level, name, VA_ARGS)
| ^~~~~~~~~~~~
/opt/ros/noetic/include/rosconsole/macros_generated.h:214:24: note: in expansion of macro ‘ROS_LOG’
214 | #define ROS_ERROR(...) ROS_LOG(::ros::console::levels::Error, ROSCONSOLE_DEFAULT_NAME, VA_ARGS)
| ^~~~~~~
/home/car/workspace_rslidar/src/rs_to_velodyne-master/src/rs_to_velodyne.cpp:213:13: note: in expansion of macro ‘ROS_ERROR’

(请问有什么方法能解决吗)
Is there any way to solve it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants