1. cmake tools
The knowledge about cmake has been introduced in the previous make and cmake , and the following is mainly the introduction of cmake software and some little knowledge in it. The download URL of cmake is: https://cmake.org/ , the interface of the software is as follows, where is the source code
which is the folder where the source code to be compiled is located. This folder contains CMakeList.txt. The compilation of cross-platform projects is generally mainly Do it through this document. where to build the binaries
It is to store the project files generated by compilation.
configure
To configure the button, it is generally the next operation to be performed when specifying the first two addresses. At this time, the following interface will appear (here an opencv library configuration is taken as an example), the first one is to select the version that is compatible with your VS, and the second is to select 64-bit, which corresponds to x64 in VS.
Generally, no error will be reported (it is best to have a tool to ensure that the code on github can be downloaded).
A few common items that need to be known here: +Add Entry
This button corresponds to the set command in cmake, which can set the values of three variables: ordinary variables, cache entries, and environment variables
UILD_SHARED_LIB
It is a global flag of add_library(). When add_library() does not specify which one [STATIC | SHARED | MODULE] is, it can decide whether to generate a dynamic library or a static library. ON: let add_library() generate .dll dynamic library, corresponding to SHARED;OFF: let add_library() generate .lib static library, corresponding to STATIC.
CMAKE_INSTALL_PREFIX
It is a cmake built-in variable, which is used to specify the installation path prefix when cmake executes the install target. The cmake -DCMAKE_INSTALL_PREFIX=<想要安装的路径>
CMAKE_BUILD_TYPE
optional execution values on the command line include:
Debug: used to build libraries or executables with debug symbols without optimization File
Release: for building optimized libraries or executables without debug symbols
RelWithDebInfo: for building less optimized libraries or executables, including debug symbols
MinSizeRel: for optimizations that do not increase object code size, to build or executable
corresponds to the command linecmake .. -D CMAKE_BUILD_TYPE="Release"
Generate
In order to generate project files, it is generally necessary to open VS with administrator privileges, and then use VS to open the where to build the binaries
generated project, so that the error report of setlocal can generally be avoided. Then find ALL build in the project, compile under debug and release respectively (select ALL build, right-click to generate) (or adopt batch generation method, the result is as shown in the figure below), until all compilations are successful. Then find INSTALL, and compile under debug and release respectively to complete the compilation of the library.
2.vcpkg tool
vcpkg is a C++ third-party library management tool, which can help C++ programmers quickly obtain and compile third-party libraries. Generally, C++ third-party libraries need to be manually compiled and configured in various environments, such as OpenMVS, and many people basically cannot compile them. With vcpkg, these libraries can be obtained with just one command, which is very convenient.
Next, we will first introduce the installation and use of the following vcpkg. It is best to have the one that comes with the computer Windows PowerShell
and git
cooperate. git
The download address is https://git-scm.com/downloads , all are installed by default, and then you can open the one that comes with the computer Windows PowerShell
to start cloning vcpkg, command: git clone https://github.com/Microsoft/vcpkg.git
, cd to the vcpkg directory, execute the script bootstrap-vcpkg.bat to get vcpkg.exe, and then you can use vcpkg to install various libraries (hey, it’s not as easy to use recently as it used to be). The command to install the third-party library: vcpkg install [name]
, the default installation is 32-bit, if you want to choose 64-bit, you can add: x64-windows at the end, the command is as follows: :vcpkg install [name]:x64-windows
. Of course, you can also add the variable name: VCPKG_DEFAULT_TRIPLET, variable value: x64-windows in the system variable, so that the default installed library is 64-bit.