Windows安装Ceres

综述

Ceres Solver is an open source C++ library for modeling and solving large, complicated optimization problems. It can be used to solve Non-linear Least Squares problems with bounds constraints and general unconstrained optimization problems. It is a mature, feature rich, and performant library that has been used in production at Google since 2010.

Ceres Solver 是一个用于建模和解决大型复杂优化问题的开源c++库。它可用于求解有界约束的非线性最小二乘问题和一般无约束优化问题。它是一个成熟的、功能丰富的、高性能的库,从2010年开始在谷歌的生产环境中使用。

本文首先给出安装各个包的前提,然后针对每一个包的安装我们都给出了相关的安装步骤文章。

我相信该教程已经对绝大多数错误进行了覆盖。
如遇任何问题欢迎随时联络: sdudzy@163.com

前提

其中:eigens,glags和glogs的教程是很相似的。suitesparse略有不同。

注意:suitesparse教程中不推荐大家自己全部自己配置再cmake。

步骤

编译安装Ceres

下载Ceres 1.14.0
下载
下载zip后解压即可,然后使用cmake编译。

设置配置信息

使用cmake首先configuration一下。
然后会出错。
然后配置你的文件,请确保你的配置文件如下:

注意在配置信息中这里的SP_ROOT就是大家下载的suitesparse文件夹,SP_ROOT_output就是大家使用cmake编译后的suitesparse输出的文件夹。
安装suitesparse 教程

注意有一些项原来的cmake配置中没有需要手动添加:
你可以检查与该表各项的情况是不是一致来设置自己的cmake。
在这里插入图片描述在这里插入图片描述

你会发现configuration结束后:我们所有需要的库都被found了。

Selecting Windows SDK version  to target Windows 10.0.17763.
Detected Ceres version: 1.14.0 from C:/local/ceres-solver-1.14.0/include/ceres/version.h
-- Disabling tests. The flags BUILD_TESTING and BUILD_SHARED_LIBS are incompatible with MSVC.
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: C:/Program Files (x86)/Eigen3/share/eigen3/cmake
-- Found Eigen version 3.3.7: C:/Program Files (x86)/Eigen3/include/eigen3
-- Enabling use of Eigen as a sparse linear algebra library.
Found BLAS: C:/local/SP_ROOT/lapack_windows/x64/libblas.lib  
-- Found LAPACK library: C:/local/SP_ROOT/lapack_windows/x64/liblapack.lib
Found AMD headers in: C:/local/SP_ROOT_output/install/include/suitesparse
Found AMD library: C:/local/SP_ROOT_output/install/lib64/libamd.lib
Found CAMD headers in: C:/local/SP_ROOT_output/install/include/suitesparse
Found CAMD library: C:/local/SP_ROOT_output/install/lib64/libcamd.lib
Found COLAMD headers in: C:/local/SP_ROOT_output/install/include/suitesparse
Found COLAMD library: C:/local/SP_ROOT_output/install/lib64/libcolamd.lib
Found CCOLAMD headers in: C:/local/SP_ROOT_output/install/include/suitesparse
Found CCOLAMD library: C:/local/SP_ROOT_output/install/lib64/libccolamd.lib
Found CHOLMOD headers in: C:/local/SP_ROOT_output/install/include/suitesparse
Found CHOLMOD library: C:/local/SP_ROOT_output/install/lib64/libcholmod.lib
Found SUITESPARSEQR headers in: C:/local/SP_ROOT_output/install/include/suitesparse
Found SUITESPARSEQR library: C:/local/SP_ROOT_output/install/lib64/libspqr.lib
Did not find Intel TBB library, assuming SuiteSparseQR was not compiled with TBB.
Found SUITESPARSE_CONFIG headers in: C:/local/SP_ROOT_output/install/include/suitesparse
Found SUITESPARSE_CONFIG library: C:/local/SP_ROOT_output/install/lib64/suitesparseconfig.lib
Found METIS library: C:/local/SP_ROOT_output/install/lib64/metis.lib
Found SuiteSparse: TRUE (found version "4.4.4") 
-- Found SuiteSparse 4.4.4, 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: C:/Program Files (x86)/gflags/lib/cmake/gflags
Detected gflags version: 2.2.2
-- Found Google Flags header in: C:/Program Files (x86)/gflags/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.
Found installed version of glog: C:/Program Files (x86)/glog/lib/cmake/glog
Detected glog version: 0.4.0
-- 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.
Performing Test CXX11_MATH_FUNCTIONS_FOUND
Performing Test CXX11_MATH_FUNCTIONS_FOUND - Success
   ==============================================================
   Compiling Ceres using C++11.  This will result in a version 
   of Ceres that will require the use of C++11 in client code.
   ==============================================================
-- Building Ceres as a shared library.
Enabling CERES_USE_EIGEN_SPARSE in Ceres config.h
Enabling CERES_NO_CXSPARSE in Ceres config.h
Enabling CERES_USE_CXX11 in Ceres config.h
Enabling CERES_USE_OPENMP in Ceres config.h
Enabling CERES_STD_UNORDERED_MAP in Ceres config.h
Enabling CERES_USING_SHARED_LIBRARY in Ceres config.h
Enabling CERES_MSVC_USE_UNDERSCORE_PREFIXED_BESSEL_FUNCTIONS in Ceres config.h
-- Build the examples.
Configuring done
Generating done

点击generate。
然后在VS中使用release模式生成ALL_BUILD和INSTALL。

使用管理员身份运行,不然会报错:
在这里插入图片描述

  • 首先是ALL_BUILD
    在这里插入图片描述
    这个过程非常慢!
    在这里插入图片描述
  • 然后是INSTALL

在这里插入图片描述
完毕后,我们需要切换到debug模式:

切换到Debug模式。然后右键单击“ceres”项目->属性->链接器->输入->附加依赖项。
在这里插入图片描述
右键属性:
这里要注意属性管理也应设为Debug模式。
在这里插入图片描述
将以下7个Release版本的库改为Debug版本的库

C:\local\SP_ROOT_output\install\lib64\libspqr.lib
C:\local\SP_ROOT_output\install\lib64\libcholmod.lib
C:\local\SP_ROOT_output\install\lib64\libccolamd.lib
C:\local\SP_ROOT_output\install\lib64\libcamd.lib
C:\local\SP_ROOT_output\install\lib64\libcolamd.lib
C:\local\SP_ROOT_output\install\lib64\libamd.lib
C:\local\SP_ROOT_output\install\lib64\suitesparseconfig.lib

调整为Debug版本库:(区别就是最后面会多一个d)

C:\local\SP_ROOT_output\install\lib64\libspqrd.lib
C:\local\SP_ROOT_output\install\lib64\libcholmodd.lib
C:\local\SP_ROOT_output\install\lib64\libccolamdd.lib
C:\local\SP_ROOT_output\install\lib64\libcamdd.lib
C:\local\SP_ROOT_output\install\lib64\libcolamdd.lib
C:\local\SP_ROOT_output\install\lib64\libamdd.lib
C:\local\SP_ROOT_output\install\lib64\suitesparseconfigd.lib

然后生成ALL_BUILD和INSTALL项目,完成Debug模式的编译和安装过程。

注意此时切换到debug模式下编译会报错:
在这里插入图片描述

此时请:

工程属性页->C/C++ ->命令行->键入/bigobj编译器
在这里插入图片描述

此时一定不要忘记设置环境变量:
在这里插入图片描述
重启电脑。

check

注意:务必配置好上面的几个环境变量。

打开cmd,切换到C:\local\ceres-solver-1.14.0_output\bin路径下的Release和Debug下,然后运行分别运行helloworld.exe,如果看到convergence的话,即收敛,说明Release和Debug下的编译均成功
在这里插入图片描述

致谢

这个过程还是比较复杂的,我主要参考:

https://blog.csdn.net/xixihaha369300/article/details/83546473
https://www.jianshu.com/p/736e89aaf788

第一篇文章很大程度上支撑了Ceres的最后的安装步骤;第二篇则主要指导了前面部分的安装步骤。

  • 1
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值