编译GraphOptim库
这个库是北大Hybrid Rotation Averaging论文开源的代码。记录编译依赖包过程:
0. 安装openssl, yum install -y openssl-devel
1. 安装 cmake-3.22.5,下载源码,看README,./bootstrap && make && sudo make install
2. gcc版本要求4.9以上
3. eigen-3.3.7
4. gflags-2.2.2
5. glog-0.4.0
先mkdir build | cd build
cmake .. -DCMAKE_INSTALL_PREFIX=path_to_res_install | make
然后,可以执行cmake/Install.md中的命令,安装到/usr/local/路径下
注意看cmake路径下的INSTALL.md,依次执行,然后将/usr/local/lib64/cmake/glog/加入
后面编译ceres时,CMakeLists.txt中:
set(Glog_DIR /usr/local/lib64/cmake/glog/)
find_package(Glog REQUIRED)
6. googletest-release-1.11.0
7. SuitSparse,通过yum安装,yum install -y suitesparse-devel
8. ceres-solver-1.14.0,
在CMakeLists.txt中的eigen3和glog的 find_packages前,加入搜索路径:
set(Eigen3_DIR path_to/eigen-3.3.7/share/eigen3/cmake)
find_package(Eigen3)
set(Glog_DIR /usr/local/lib64/cmake/glog)
find_package(Glog)
9. GraphOptim
在CMakeLists.txt每个find_packages前加上
set(XXX_DIR path_to_share_cmake)
然后设定具体的路径:
set(GTEST_ROOT path_to/googletest-release-1.11.0)
set(GTEST_INCLUDE_DIRS ${GTEST_ROOT}/include ${GTEST_ROOT}/include/gtest ${GTEST_ROOT}/include/gmock)
set(GTEST_LIBRARIES ${GTEST_ROOT}/lib64/libgtest_main.a ${GTEST_ROOT}/lib64/libgtest.a ${GTEST_ROOT}/lib64/libgmock.a
${GTEST_ROOT}/lib64/libgmock_main.a ${GTEST_MAIN_LIBRARY} ${GTEST_LIBRARY})
有时候,需要在../cmake/FindEigen3.cmake 中,unset(EIGEN3_INCLUDE_DIRS)后面,增加具体的变量(根据make的情况,再配置):
set(EIGEN3_ROOT path_to/eigen-3.3.7)
set(EIGEN3_INCLUDE_DIRS ${EIGEN3_ROOT}/include/eigen3)
set(EIGEN3_LIBRARIES ${EIGEN3_ROOT}/share)
遇到的问题:
*** No rule to make target 'XXX/googletest-release-1.11.0/lib/libgtest_main.a',
原因是在CMakeLists.txt中,GTEST_LIBRARIES的路径写错了,应该是lib64,我原先写的lib/,找不到文件出错。
10. 不用make install,使用的时候,
set(GraphOptim_ROOT path_to_GraphOptim_main)
然后,
set(YOURMODULE_EXTERNAL_LIBRARIES
GraphOptim_ROOT/lib/libgopt.a
GraphOptim_ROOT/build/3rd_party/Graclus/libgraclus.a
... ...)
set(YOURMODULE_EXTERNAL_INCLUDE_DIRS
GraphOptim_ROOT/src/
... ... )
然后,在编译lib库或者execute文件时,包含上graphOptim的 include路径 和lib路径。
- 点赞
- 收藏
- 关注作者
评论(0)