很多人一开始使用Sophus库时会碰到下面的错误:
CMake Error at CMakeLists.txt:5 (find_package):
By not providing "FindSophus.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "Sophus", but
CMake did not find one.
Could not find a package configuration file provided by "Sophus" with any
of the following names:
SophusConfig.cmake
sophus-config.cmake
Add the installation prefix of "Sophus" to CMAKE_PREFIX_PATH or set
"Sophus_DIR" to a directory containing one of the above files. If "Sophus"
provides a separate development package or SDK, be sure it has been
installed.
-- Configuring incomplete, errors occurred!
这时,CMakeLists.txt文件中查找Sophus库的语句多半是这么写的:
find_package(Sophus REQUIRED)
提供一种解决方案,观看错误信息,其实就是找不到Sophus库和头文件的内容:
set(Sophus_INCLUDE_DIRS "放置你的Sophus头文件文件夹路径")
set(Sophus_LIBS "放置你的Sophus库文件的文件夹路径,指明相应的库文件")
比如,我的是这样的:
set(Sophus_INCLUDE_DIRS "/usr/local/include/sophus")
set(Sophus_LIBS "/usr/local/lib/libSophus.so")
include_directories(
${Sophus_INCLUDE_DIRS}
)
然后再将你的执行文件链接上Sophus库文件
这样的话,上述编译错误应该就可以消失了。