问题描述:
刚开始跟着PCL tutorials官方教程学习PCL点云库,先创建pcd_write.cpp文件,然后编写CMakeLists.txt文件,官方提供的CMakeLists.txt文件内容如下:
cmake_minimum_required(VERSION 2.8 FATAL_ERROR) project(pcd_write) find_package(PCL 1.2 REQUIRED) include_directories(${PCL_INCLUDE_DIRS}) link_directories(${PCL_LIBRARY_DIRS}) add_definitions(${PCL_DEFINITIONS}) add_executable (pcd_write pcd_write.cpp) target_link_libraries (pcd_write ${PCL_LIBRARIES})
讯享网
编译:
在当前目录下打开终端并进行cmake编译,
讯享网mkdir build cd build cmake .. make
编译后报如下错误:
error: ISO C++ forbids declaration of ‘point’ with no type [-fpermissive] for (auto& point: cloud) warning: range-based ‘for’ loops only available with -std=c++11 or -std=gnu++11 for (auto& point: cloud) error: request for member ‘y’ in ‘point’, which is of non-class type ‘int’ point.y = 1024 * rand () / (RAND_MAX + 1.0f); error: request for member ‘y’ in ‘point’, which is of non-class type ‘int’ point.y = 1024 * rand () / (RAND_MAX + 1.0f); error: request for member ‘z’ in ‘point’, which is of non-class type ‘int’ point.z = 1024 * rand () / (RAND_MAX + 1.0f);
解决方案:
从第二句warning的警告可以知道基于范围的for循环仅适用于-std=c++11 或 -std=gnu++11标准,因此需要在CMakeLists.txt文件中加入C++11标准,最终的CMakeLists.txt文件内容如下:
讯享网cmake_minimum_required(VERSION 2.8 FATAL_ERROR) # 指定为C++11 标准 set(CMAKE_CXX_STANDARD 11) project(pcd_write) find_package(PCL 1.2 REQUIRED) include_directories(${PCL_INCLUDE_DIRS}) link_directories(${PCL_LIBRARY_DIRS}) add_definitions(${PCL_DEFINITIONS}) add_executable (pcd_write pcd_write.cpp) target_link_libraries (pcd_write ${PCL_LIBRARIES})
接下来就可以顺利通过编译了。


版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容,请联系我们,一经查实,本站将立刻删除。
如需转载请保留出处:https://51itzy.com/kjqy/62027.html