1、下载lidar_align
sudo apt-get install libnlopt-dev
cd lidar_align-master
mkdir build
cd build
cmake .. && make -j4
此时可能会出现以下问题:
问题1:
CNake Error at /usr /share/cnake-3.10/Nodules/FindPackageHandlestandardArgs.cmake:137 (nessage);could NOT find NLOPT (missing: NLOPT_INCLUDE_DIR NLOPT_LIBRARY)
Call stack (most recent call first):
/usr/share/cnake-3.10/NModules/FindPackageHandleStandardArgs.cnake:378(_FPHSA_FAILURENLOPTConfig.cmake:65 (find_package_handle_standard_args)
CMakeLists.txt: 18 (find_package)
-- Configuring incomplete, errors occurred!
see also "/home/findlab/lidar_align-naster/build /CMakeFiles/CNakeoutput.log".See also "/hone /findlab/lidar_align-naster/build/CMakeFiles/CNakeError.log".
解决方法:
在lidar_align-master文件夹中的CMakeLists.txt添加以下代码:
list(APPEND CMAKE_FIND_ROOT_PATH ${PROJECT_SOURCE_DIR})
set (CMAKE_PREFIX_PATH "/usr/local/lib/cmake/nlopt")
问题2:
/usr/include/flann/ext/lz4.h:196:57: error: conflicting declaration 'typedef struct LZ4_ strean_t LZ4_ strean_t'typedef struct { long long table[LZ4_STREANSIZE_U64];} LZ4_strean_t;
解决办法:
在终端中执行以下命令
sudo mv /usr/include/flann/ext/lz4.h /usr/include/flann/ext/lz4.h.bak
sudo mv /usr/include/flann/ext/lz4hc.h /usr/include/flann/ext/lz4.h.bak
sudo ln -s /usr/include/lz4.h /usr/include/flann/ext/lz4.h
sudo ln -s /usr/include/lz4hc.h /usr/include/flann/ext/lz4hc.h
问题3 :
/usr/include/pcl-1.10/pcl/point_types.h:525:1: error: ‘minusscalar’ is not a member of ‘pcl::traits’
525 | POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::_PointWithViewpoint,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
解决办法:
在lidar_align-master文件中的CMakeLists.txt里增加以下代码:
set(CMAKE_CXX_STANDARD 14)
问题4:
In file included from /home/hzw/lidar_align-master/src/aligner.cpp:1:
/home/hzw/lidar_align-master/include/lidar_align/aligner.h:7:10: fatal error: nlopt.hpp: 没有那个文件或目录
7 | #include <nlopt.hpp>
| ^~~~~~~~~~~
compilation terminated.
make[2]: *** [CMakeFiles/lidar_align.dir/build.make:76:CMakeFiles/lidar_align.dir/src/aligner.cpp.o] 错误 1
make[1]: *** [CMakeFiles/Makefile2:1165:CMakeFiles/lidar_align.dir/all] 错误 2
make: *** [Makefile:141:all] 错误 2
解决办法:
安装nlopt
git clone https://github.com/stevengj/nlopt
cd nlopt
mkdir build
cd build
cmake .. && make -j4
sudo make install
最终编译成功