遇到的问题
1.CMake Error at CMakeLists.txt:155 (find_package):
By not providing "Findabsl.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "absl", but
CMake did not find one.
缺少absl 需要安装abseil并编译
参考 http://t.csdnimg.cn/iXcWl http://t.csdnimg.cn/et3H1
2. CMake Error at CMakeLists.txt:161 (message):
The version of abseil installed on the system is need at least 20240116.2
解决方法 首先是确定安装了20240116.2以上的abseil
然后在ceres-solver的cmakelist.txt文件中搜索
# if (absl_VERSION VERSION_LESS 20240116.2)
# message(FATAL_ERROR "The version of abseil installed on the system is " ${absl_VERSION} " need at least 20240116.2")
# endif()
注释掉
3.CMake Error at /usr/local/share/cmake-3.27/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
Could NOT find GTest (missing: GTEST_LIBRARY GTEST_INCLUDE_DIR
GTEST_MAIN_LIBRARY) (Required is at least version "1.14.0")
Call Stack (most recent call first):
/usr/local/share/cmake-3.27/Modules/FindPackageHandleStandardArgs.cmake:600 (_FPHSA_FAILURE_MESSAGE)
/usr/local/share/cmake-3.27/Modules/FindGTest.cmake:270 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
CMakeLists.txt:182 (find_package)
这是没有找到gtest的路径 首先要确保gtest已经安装了
cd /usr/src/googletest/googletest
sudo rm -rf build
sudo mkdir build
cd build
sudo cmake .. -DCMAKE_INSTALL_PREFIX=/usr/local
sudo make
4.CMake Error at internal/ceres/CMakeLists.txt:370 (target_link_libraries):
Target "test_util" links to:
GTest::gmock
but the target was not found. Possible reasons include:
* There is a typo in the target name.
* A find_package call is missing for an IMPORTED target.
* An ALIAS target is missing.
CMake Error at internal/ceres/CMakeLists.txt:391 (target_link_libraries):
Target "array_utils_test" links to:
GTest::gmock_main
but the target was not found. Possible reasons include:
* There is a typo in the target name.
* A find_package call is missing for an IMPORTED target.
* An ALIAS target is missing.
Call Stack (most recent call first):
internal/ceres/CMakeLists.txt:407 (ceres_test)
CMake Error at internal/ceres/CMakeLists.txt:391 (target_link_libraries):
Target "array_selector_test" links to:
GTest::gmock_main
but the target was not found. Possible reasons include:
* There is a typo in the target name.
* A find_package call is missing for an IMPORTED target.
* An ALIAS target is missing.
解决方法 这是没找到gmock的路径 在cmake时给定路径的参数可以解决
先建立软链接
ls /usr/local/lib | grep libgtest
ls /usr/local/lib | grep libgmock
ls /usr/local/include | grep gtest
ls /usr/local/include | grep gmock
然后在cmake指定相应路径
cmake .. -DCMAKE_INSTALL_PREFIX=/usr/local -DGTEST_LIBRARY=/usr/local/lib/libgtest.a -DGTEST_MAIN_LIBRARY=/usr/local/lib/libgtest_main.a -DGMOCK_LIBRARY=/usr/local/lib/libgmock.a -DGMOCK_MAIN_LIBRARY=/usr/local/lib/libgmock_main.a
最后终于成功编译ceres-solver
-- Adding librt to SuiteSparse_config libraries (required on Linux & Unix [not OSX] if SuiteSparse is compiled with timing).
-- Found SuiteSparse 5.1.2, building with SuiteSparse.
-- Building without Apple's Accelerate sparse support.
-- Building Ceres as a static library.
-- Enabling CERES_USE_EIGEN_SPARSE in Ceres config.h
-- Enabling CERES_NO_CUDSS in Ceres config.h
-- Enabling CERES_NO_ACCELERATE_SPARSE in Ceres config.h
-- Enabling CERES_NO_CHOLMOD_FLOAT in Ceres config.h
-- Build the examples.
-- Configuring done (0.2s)
-- Generating done (1.3s)