ceres-solver在vs2013_x64编译记录(附编译完成资源)

1. 背景介绍

因为相机新标定算法开发需要,借助ceres库求解非线性方程的能力,基于大量相机标定图像数据,求解相机的内外参数。ceres-solver在windows上编译较为麻烦,经常因为勾选的不正确导致最终编译的库不能正常适用,特记录该过程,不想自己编译的直接看最后编译完成的资源链接。

2. 下载清单

ceres-solver1.13(https://ceres-solver.googlesource.com/ceres-solver/),ceres官方提示在小于等于1.14版本时,c++11不是必要的。

eigen3.3(http://eigen.tuxfamily.org/index.php?title=Main_Page),

gflag2.2.1(https://gitcode.net/mirrors/gflags/gflags/-/releases?spm=1033.2243.3001.5877),

glog0.3.5 (https://gitcode.net/mirrors/google/glog/-/releases?spm=1033.2243.3001.5877)

suitesparse-metis-for-windows(https://gitcode.net/mirrors/jlblancoc/suitesparse-metis-for-windows?utm_source=csdn_github_accelerator).

在这里插入图片描述

3 详细编译步骤

新建名为ceres的文件夹,将下载的第三方依赖包解压到该目录下,并且在该目录下新建一个install文件夹以存放后面步骤编译的结果。
在这里插入图片描述

3.1 编译Eigen3.3

Eigen本身是一种源码运行模式,无需编译,这里为了统一所有第三库,用cmake进行编译, 选择vs2013,x64. 点击“Configure” 之后按照如下配置。通常为了减小库的大小,节省编译时间,所有编译的test内容都不勾选,主要注意以下两项,其他按照默认勾选。然后点击“Generate”,应该不会遇到报错,再点击“Open Project"打开vs2013工程,在配置管理器中选择Release和x64,然后右键 ALL_BUILD 点击”生成“,生成成功后右键”INSTALL“选择”生成“,这样Eigen3用vs2013 release x64编译的库就生成并安装在ceres/install/eigen3下。
选择vs2013 x64平台编译:
选择vs2013 x64
注意以下两项:

取消 BUILD_TESTING,取消有关TEST的相关项
配置 CMAKE_INSTALL_PREFIX, 选择install的路径 ceres/install/eigen3

在这里插入图片描述
依次右键ALL_BUILD选择“生成”,成功后右键INSTALL选择“生成”
在这里插入图片描述
自动安装到设置的目录下
在这里插入图片描述

3.2 编译gflag2.2

同样地选择vs2013 x64编译器,在配置时,只需要注意取消有关TEST,勾选生成共享lib,以及设置安装目录。在"Configure", “Generate”, 然后”Open Project“后,分别选择Release x64和Debug x64下,去生成ALL_BUILD以及 INSTALL, 这样gflag编译的库就放在了ceres/install/gflag下。

注意以下几项

取消 BUILD_TESTING
勾选 BUILD_SHARED_LIBS
设置 CMAKE_INSTALL_PREFIX 到 ceres/install/gflag
其他默认

在这里插入图片描述
在这里插入图片描述

3.3 编译glog 0.3.5

glog的编译有所不同,是因为链接提供的资源是已经提供了.sln的工程,用vs2013可以直接打开,提示迁移和升级,选择确定即可。用vs2013迁移和升级后,在配置管理器中,新建活动解决方案平台x64(原来只有win32)。然后分别在Release x64和Debug x64下右键libglog并生成。

glog包已经有.sln的工程,不用cmake。在这里插入图片描述
确认工程的迁移和版本升级
在这里插入图片描述
配置管理器中新增x64的解决方案平台
在这里插入图片描述
右键libglog选择“生成”
在这里插入图片描述
glog的工程生成库的路径因为不像之前cmake中进行了重新配置,所以需要手动将glog的.lib和.dll以及头文件放置到ceres/install/glog中,头文件在glog0.3.5/src/windows下,库文件在glog0.3.5/x64/下,分别放置到ceres/install/glog/include和ceres/install/glog/lib中
在这里插入图片描述
在这里插入图片描述

3.4 编译suitesparse-metis-for-windows

suitesparse配置项目虽然多,但是重点的还是上面提及的几个,取消TEST,配置安装路径,勾选生成共享库。然后打开工程分别选择Release x64和Debug x64下,去生成ALL_BUILD以及 INSTALL, 这样suitesparse-windows编译的库就放在了ceres/install/sutesparse-metis-for-windows下。

设置 CMAKE_INSTALL_PREFIX 为 ceres/install/sutesparse-metis-for-windows
EXECUTABLE_OUTPUT_PATH会随之改变到对应的bin文件夹下,注意看一下是否有改变,否则手动配置
设置 LIBRARY_OUTPUT_PATH 为 ceres/install/sutesparse-metis-for-windows/lib
勾选 SHARED
取消 HAVE_COMPLEX
其他配置如图对应选择

在这里插入图片描述

3.5 ceres-solver编译

将前面所需要的第三方库编译好之后,可以开始编译ceres了。ceres编译之前容易失败的原因就在于需要配置的路径和选择的内容较多,容易出错。在编译ceres时需要点击configure查看报错,对应会提示哪些东西未配置或未找到。当这一项配置好之后,再Configure,会提示下一项的配置,因此,需要来回Configure多次,并且,需要重点注意的是,suitesparse每次会默认不勾选,所以一定要记得最终勾选上。跟之前第三方配置时一致,取消有关TEST,设置install路径,勾选shared,不同的在于需要配置许多额外的库,如libpack。并且ceres配置时应该勾选advanced,这样能够看到更全的项目。

配置 AMD_INCLUDE_DIR 和 AMD_LIBRARY 为suitesparse-metis-for-windows中的include和lib
配置 BLAS_blas_LIBRARY 为 suitesparse-metis-for-windows 下lapack_windows/x64/libblas.lib, 其他的BLAS相关都可不配置
勾选 BUILD_SHARED_LIBS
配置 CAMD、CCOLAMD、CHOLMOD、COLAMD 的inlcude_Dir和LIBRARY 为suitesparse-metis-for-windows中的include和lib
配置 CMAKE_INSTALL_PREFIX 为ceres/install/ceres,其他的CAMKE相关保持默认即可
勾选 CUSTOM_BLAS
取消 CXSPARSE, 非必要的
勾选 EIGENSPARSE
配置 Eigen3_DIR 为 ceres/install/eigen3/share/eigen3/cmake,这样EIGEN_INCLUDE_DIR会自动识别
勾选 GFLAGS
配置 gflags_DIR 为ceres/install/gflag/lib/camke/gflags
配置 GLOG_INCLUDE_DIR和GLOG_LIBRARY为ceres/install/glog下的include和lib/Release/libglog.lib
勾选 LAPACK
配置 LAPACK_lapack_LIBRARY  为 suitesparse-metis-for-windows 下lapack_windows/x64/liblapck.lib, 其他的LAPACK相关都可不配置
勾选 OPENMP
勾选 SCHUR_SPECIALIZATIONS
勾选 SUITESPARSE 特别注意该选项会自动取消,注意勾选!!
配置 SUITESPARSE 的include和library 为suitesparse-metis-for-windows中的include和lib

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在所有配置好之后configure应该是如下的结果,重点看found…的内容,如Found Eigen version 3.3.5, Found LAPACK library, Found AMD headers等,Eigen, gflag, glog等一定是处于能found的状态。基本上所有的都能找到,除了TBB提示not found。总之,核对如下的found内容,未找到的再次核对上面cmake中是否未配置。

Detected Ceres version: 1.13.0 from E:/Code/Ceres/ceres-solver/include/ceres/version.h
No preference for use of exported Eigen CMake configuration set, and no hints for include directory provided. Defaulting to preferring an installed/exported Eigen CMake configuration if available.
Found installed version of Eigen: E:/Code/Ceres/install/eigen3/share/eigen3/cmake
-- Found Eigen version 3.3.5: E:/Code/Ceres/install/eigen3/include/eigen3

   ===============================================================
   Enabling the use of Eigen as a sparse linear algebra library 
   for solving the nonlinear least squares problems. Enabling 
   this option results in an LGPL licensed version of 
   Ceres Solver as the Simplicial Cholesky factorization in Eigen
   is licensed under the LGPL. 
   ===============================================================

-- Found LAPACK library: E:/Code/Ceres/suitesparse-metis-for-windows-master/lapack_windows/x64/liblapack.lib;E:/Code/Ceres/suitesparse-metis-for-windows-master/lapack_windows/x64/libblas.lib
-- Found BLAS library: E:/Code/Ceres/suitesparse-metis-for-windows-master/lapack_windows/x64/libblas.lib
Found AMD headers in: E:/Code/Ceres/install/suitesparse-metis-for-windows/include/suitesparse
Found AMD library: E:/Code/Ceres/install/suitesparse-metis-for-windows/lib
Found CAMD headers in: E:/Code/Ceres/install/suitesparse-metis-for-windows/include/suitesparse
Found CAMD library: E:/Code/Ceres/install/suitesparse-metis-for-windows/lib
Found COLAMD headers in: E:/Code/Ceres/install/suitesparse-metis-for-windows/include/suitesparse
Found COLAMD library: E:/Code/Ceres/install/suitesparse-metis-for-windows/lib
Found CCOLAMD headers in: E:/Code/Ceres/install/suitesparse-metis-for-windows/include/suitesparse
Found CCOLAMD library: E:/Code/Ceres/install/suitesparse-metis-for-windows/lib
Found CHOLMOD headers in: E:/Code/Ceres/install/suitesparse-metis-for-windows/include/suitesparse
Found CHOLMOD library: E:/Code/Ceres/install/suitesparse-metis-for-windows/lib
Found SUITESPARSEQR headers in: E:/Code/Ceres/install/suitesparse-metis-for-windows/include/suitesparse
Found SUITESPARSEQR library: E:/Code/Ceres/install/suitesparse-metis-for-windows/lib
Did not find TBB library (optional SuiteSparse dependency)
Did not find Intel TBB library, assuming SuiteSparseQR was not compiled with TBB.
Found SUITESPARSE_CONFIG headers in: E:/Code/Ceres/install/suitesparse-metis-for-windows/include/suitesparse
Found SUITESPARSE_CONFIG library: E:/Code/Ceres/install/suitesparse-metis-for-windows/lib
Did not find METIS library (optional SuiteSparse dependency)
Found SuiteSparse: TRUE (found version "5.4.0") 
-- Found SuiteSparse 5.4.0, building with SuiteSparse.
-- Building without CXSparse.
No preference for use of exported gflags CMake configuration set, and no hints for include/library directories provided. Defaulting to preferring an installed/exported gflags CMake configuration if available.
Found installed version of gflags: E:/Code/Ceres/install/gflag/lib/cmake/gflags
Detected gflags version: 2.2.1
-- Found Google Flags header in: E:/Code/Ceres/install/gflag/include, in namespace: google
No preference for use of exported glog CMake configuration set, and no hints for include/library directories provided. Defaulting to preferring an installed/exported glog CMake configuration if available.
Failed to find installed glog CMake configuration, searching for glog build directories exported with CMake.
Failed to find an installed/exported CMake configuration for glog, will perform search for installed glog components.
-- Found Google Log (glog). Assuming glog was built with gflags support as gflags was found. This will make gflags a public dependency of Ceres.
-- Building with OpenMP.
Looking for C++ include unordered_map
Looking for C++ include unordered_map - found
Performing Test HAVE_UNORDERED_MAP_IN_STD_NAMESPACE
Performing Test HAVE_UNORDERED_MAP_IN_STD_NAMESPACE - Success
-- Found unordered_map/set in std namespace.
Looking for C++ include memory
Looking for C++ include memory - found
Performing Test HAVE_SHARED_PTR_IN_STD_NAMESPACE
Performing Test HAVE_SHARED_PTR_IN_STD_NAMESPACE - Success
-- Found shared_ptr in std namespace using <memory> header.
-- Building Ceres as a static library.
Enabling CERES_USE_EIGEN_SPARSE in Ceres config.h
Enabling CERES_NO_CXSPARSE in Ceres config.h
Enabling CERES_USE_OPENMP in Ceres config.h
Enabling CERES_STD_UNORDERED_MAP in Ceres config.h
Enabling CERES_MSVC_USE_UNDERSCORE_PREFIXED_BESSEL_FUNCTIONS in Ceres config.h
-- Do not build any example.
Configuring done

点击generate,会提示如下警告,这些就是说未能自动的加入到.sln的工程中,在open project后我们需要手动配置这些库。
在这里插入图片描述
打开ceres编译的工程,右键ceres选择属性,如同日常配置opencv等库一样,把刚才警告的库的头文件、lib路径和附加依赖项加进去,着重检查刚才generate产生的警告,把suitesparse-metis-for-windows的相关llb路径和附加依赖项添加到ceres工程
在这里插入图片描述
以下是ceres项目属性中附加包含目录:
在这里插入图片描述
以下是ceres项目属性中附加库目录,分别是Release和Debug下的
在这里插入图片描述
在这里插入图片描述
以下是ceres项目属性Release下的附加依赖项

gflags.lib
libglog.lib
liblapack.lib
libblas.lib
shlwapi.lib
kernel32.lib
user32.lib
gdi32.lib
winspool.lib
shell32.lib
ole32.lib
oleaut32.lib
uuid.lib
comdlg32.lib
advapi32.lib
libamd.lib
libbtf.lib
libcamd.lib
libccolamd.lib
libcholmod.lib
libcolamd.lib
libcxsparse.lib
libklu.lib
libldl.lib
libspqr.lib
libumfpack.lib
suitesparseconfig.lib

以下是ceres项目属性Debug下的附加依赖项

gflags.lib
libglog.lib
liblapack.lib
libblas.lib
shlwapi.lib
kernel32.lib
user32.lib
gdi32.lib
winspool.lib
shell32.lib
ole32.lib
oleaut32.lib
uuid.lib
comdlg32.lib
advapi32.lib
libamdd.lib
libbtfd.lib
libcamdd.lib
libccolamdd.lib
libcholmodd.lib
libcolamdd.lib
libcxsparsed.lib
libklud.lib
libldld.lib
libspqrd.lib
libumfpackd.lib
suitesparseconfigd.lib

Debug可能会警告库冲突,在如下位置忽略特定默认库 msvcrt.lib
在这里插入图片描述
完成ceres属性所有设置后,Release和Debug分别生成ALL_BUILD和INSTALL. 完成ceres的编译
在这里插入图片描述

编译完成

上述所有资源以及编译完成的包,无需积分:https://download.csdn.net/download/weixin_43956164/84993720

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

leaf_csdn

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值