Because of the company's business development needs, it is necessary to switch from linux to windows, which means that people who have not used windows for about 4 years need to port the code on linux to windows. The following are some workflows for compiling colmap and openmvg on windows.
Colmap cross-platform porting (combination of vcpkg and cmake)
1. Libraries that need to be installed manually
-
Install cmake, https://cmake.org/download/ download and install
添加环境变量(cmake 安装位置),如下:
-
Install vs2019, https://visualstudio.microsoft.com/zh-hans/downloads/ download and install
添加环境变量如下:
The purpose of D:\vs2019\VC\Tools\MSVC\14.28.29333\bin\Hostx64\x64 is to configure cl.exe
-
Install qt5, https://download.qt.io/official_releases/qt/5.9/5.9.3/ download and install
添加环境变量如下:
The effect of cmake find Qt is as follows:
- Install nvidia driver and cudn
Query the driver according to your own graphics card https://www.nvidia.cn/geforce/drivers/ , your computer is 1660ti after installing the driver, nvidia-smi can see the following effect:
The cudn installation method is like https://blog.csdn.net/u010618587/article/details/82940528 , do not install the family bucket, otherwise the previous driver will be covered. After the installation is complete, add environment variables according to the blog method and test whether cudn is running normally Success, and finally enter nvcc -V on the command line, as shown below to indicate the end of the installation:
-
cgal installation download link cgal
添加环境变量如下:
2. Libraries installed through vcpkg
git clone https://github.com/microsoft/vcpkg
cd vcpkg
./bootstrap-vcpkg.sh
- ceres solver, if it is installed manually, it is very troublesome, so here it is installed by vcpkg
vcpkg install ceres[suitesparse,cxsparse]:x64-windows --recurse
At the same time, modify CeresConfig.cmake under the vcpkg-master\packages\ceres_x64-windows\share\ceres path and change it to the following (otherwise cmake cannot find ceres)
- vcpkg installs freeimage, glew and boost as follows:
After the installation here, you need to modify the CmakeLists of colmap, as follows: (windows is too pitted, case-sensitive)
3. cmake compiles colmap
Enter the build folder and enter
cmake -G "Visual Studio 16 2019" -DCMAKE_TOOLCHAIN_FILE=D:\windows_colmap\colmap\vcpkg-master\scripts\buildsystems\vcpkg.cmake ..
The cmake log is as follows:
There is no error in cmake. The last step is to open the COLMAP.sln file in the build folder, change the mode to release, and wait for the build solution to compile. After completion, it is as follows (colmap.exe is in the build\src\exe\Release directory) :
openmvg cross-platform porting
-
vcpkg install openmvg[core,openmp]:x64-windows
遇到长时间不能下载的库,手动下载,放到vcpkg 文件夹中的download 里面 vcpkg 安装openmvg 和colmap 不同,colmap 会直接编译好生成可执行文件;openmvg只会生成静态库文件(lib文件)
-
cmake -G "Visual Studio 16 2019" - DCMAKE_TOOLCHAIN_FILE=D:\windows_colmap\colmap\vcpkg-master\scripts\buildsystems\vcpkg.cmake ../src/
在build 文件中执行上条cmake,会得到以下:
点击openMVG.sln 文件,打开vs2019,将debug 改成release ,执行build solution ,如下
The generated executable file paths and results are as follows: