- Visual Studio 2019: 16.9.2
- Eigen: 3.5.0
- glog: 0.5.0
- gflags: 3.0.2
- SuiteSparse: 3.1
- Ceres Solver: 2.0.0
Install CMake (3.5 or later) if you haven't.
1. Make directories following the official guide.
{root}/ceres
For my PC, {root}
is C:/Users/hjoon
. Note, if {root}
is too long, compiling suitesparse
may give an error related to path lengths.
2. Prepare Eigen (3.3 and later)
cd "{root}\ceres"
git clone https://gitlab.com/libeigen/eigen.git
We need Eigen3 for Ceres.
cd "{root}\ceres\eigen"
mkdir build
cd build
cmake ..
You should see the needed Eigen3Config.cmake
inside eigen/build
.
3. Prepare glog (0.3.1 or later)
cd "{root}\ceres"
git clone https://github.com/google/glog.git
In {root}\ceres\glog\CMakeList.txt
line 20, make sure BUILD_SHARED_LIBS
is set to ON
(default) to generate .dll
.
option (BUILD_SHARED_LIBS "Build shared libraries" ON)
Set output directory by adding the following in {root}\ceres\glog\CMakeList.txt
(e.g., line 13).
set (CMAKE_INSTALL_PREFIX "{root}/ceres/glog/install")
Build:
cd "{root}\ceres\glog"
mkdir build
cd build
cmake ..
- Open Visual Studio (2019) as administrator and open the project:
build\glog.sln
- Set to Release x64, and build
ALL_BUILD
thenINSTALL
- This should generate
include
,lib
, andbin
folders inside:{root}\ceres\glog\install
4. Prepare gflags
cd "{root}\ceres"
git clone https://github.com/gflags/gflags.git
Set output directory by adding the following in {root}\ceres\gflags\CMakeList.txt
(e.g., line 417).
set (CMAKE_INSTALL_PREFIX "{root}/ceres/gflags/install")
Build:
cd "{root}\ceres\gflags"
mkdir gflags-build
cd gflags-build
cmake ..
- Open Visual Studio (2019) as administrator and open the project:
gflags-build\gflags.sln
- Set to Release x64, and build
ALL_BUILD
thenINSTALL
- This should generate
include
,lib
folders inside:{root}\ceres\gflags\install
- This should generate
5. Prepare SuiteSparse
According to: https://www.jianshu.com/p/736e89aaf788,
This is not a dependent library that must be installed. However, if installed, it will improve the computational performance of Ceres for sparse matrices, and provide more available optimization algorithms. So although the installation process of Ceres will be more complicated after adding this library, it is still recommended to install.
cd "{root}\ceres"
git clone https://github.com/jlblancoc/suitesparse-metis-for-windows.git
Rename the folder name for convenience:
move .\suitesparse-metis-for-windows\ .\suitesparse
Change output directory in {root}\ceres\suitesparse\CMakeList.txt
line 47, from:
set(CMAKE_INSTALL_PREFIX "${${PROJECT_NAME}_BINARY_DIR}/install" CACHE PATH "Prefix prepended to install directories" FORCE)
to:
set(CMAKE_INSTALL_PREFIX "${${PROJECT_NAME}_BINARY_DIR}/../install" CACHE PATH "Prefix prepended to install directories" FORCE)
Build:
cd "{root}\ceres\suitesparse"
mkdir build
cd build
cmake ..
- Open Visual Studio (2019) as administrator and open the project:
build\SuiteSparseProject.sln
- Set to Release x64, and build
ALL_BUILD
thenINSTALL
(may take a few minutes)- This should generate
include
,lib
folders inside:{root}\ceres\suitesparse\install
- This should generate
6. Build Ceres
cd "{root}\ceres"
git clone https://ceres-solver.googlesource.com/ceres-solver
- Open CMake GUI
- Set input source code to
{root}/ceres/ceres-solver
- Set output build directory to
{root}/ceres/ceres-solver/ceres-build
- Set input source code to
- Click
Configure
, choose generatorVisual Studio 16 2019
, set platform tox64
, then clickFinish
. This will initially generate many errors.
- Set output directory by setting
CMAKE_INSTALL_PREFIX
to{root}\ceres\ceres-install
- Uncheck
BUILD_EXAMPLES
andBUILD_TESTING
- Click
Add Entry
, and add the following four entries:-
SUITESPARSE_CHECK_INCLUDE_DIRS
asPATH
to{root}/ceres/suitesparse/install/include
-
SUITESPARSE_CHECK_LIBRARY_DIRS
asPATH
to{root}/ceres/suitesparse/install/lib
-
BLAS_LIBRARIES
asFILEPATH
to{root}/ceres/suitesparse/lapack_windows/x64/libblas.lib
-
LAPACK_LIBRARIES
asFILEPATH
to{root}/ceres/suitesparse/lapack_windows/x64/liblapack.lib
-
- Check
SUITESPARSE
andLAPACK
- Set
Eigen3_DIR
to{root}/ceres/eigen/build
(whereEigen3Config.cmake
is located)
- Click
Configure
again thenGenerate
.
- Open Visual Studio (2019) as administrator and open the project:
ceres-build\Ceres.sln
- Set to Release x64, and build
ALL_BUILD
thenINSTALL
(may take a few minutes)- This should generate
include
,lib
, andCMake
folders inside:{root}\ceres\ceres-install
- This should generate