Download and install cmake3.0.1
To compile the source code of opencv2.4.9 by yourself, you must first download the compilation tool. cmake is the most widely used compilation tool.
The following is an introduction to cmake:
Cmake is a cross-platform installation (Compilation) tool. You can use simple statements to describe the installation (compilation process) of all platforms ). He can output a variety of makefiles or project files and test the c features supported by the compiler, similar to automake in UNIX. Only the cmake configuration file is named cmakelists.txt. Cmake does not directly construct the final software, but generates standard construction files (such as UNIX makefile or Windows visual c Projects/workspaces), and then uses them in a general construction mode. This allows developers familiar with an integrated development environment (IDE) to construct their software in a standard way, this native system construction capability of various platforms is different from other similar systems such as cmake and scons.
Cmake can compile source code, create a program library, generate an adapter (wrapper), and construct an execution file in any order. Cmake supports In-Place Construction (the binary file and the source code are in the same directory tree) and out-of-place Construction (the binary file is in another directory ), therefore, it is easy to construct multiple binary files from the same source code directory tree. Cmake also supports static and dynamic library construction.
"Cmake" is short for "cross platform make. Although the name contains "make", the common "make" systems on cmake and Unix are separated and higher.
Through the above introduction, we know that we can use the cmake tool to compile the source code into the vs2010 project file, this allows us to build multiple examples or tutorial projects in different project teams under.
You can find the latest cmake installation file on the official website of cmake, www.cmake.org.
SelectResources-->Download
Select the file"CMake-3.0.1-win32-x86.exe"Download, a total of 10.78 MB, and can be completed soon.
After the download is complete, double-click the installation program to start cmake installation.
The installation is very simple. It is basically "Next" until the last step is "completed ".
After the installation is complete, you can find the installed cmake3.0.1 program shortcut in the "Start" menu"Cmake (cmake-Gui)"
After the installation, compile the opencv source code.
Opencv2.4.9 source code compilation
Assume that the source code of opencv2.4.9 has been downloaded and installed. (If you do not know how to do this step, please refer to another tutorial. ")
In the Start Menu, clickCmake (cmake-Gui )",Open the cmake program. The compilation setting page is displayed. As shown in
In"Where is the source code"In the option text box, enter the directory path of the opencv source code. You can click"Browse source..."Select a folder. Select a path based on the actual location of the source code installation. Here, select"H:/opencv/sources".
In"Where to build the Binaries"In the option text box, enter the file directory path for the sample project and source code to be built. Here, select" H:/opencv/SOLUTION "in the same folder as the source code ".
After entering the source code path and the generated path, click"Configure"Button
If this is the first configuration, a page will pop up to generate the project target environment. Select "Visual Studio 10 2010 options" and select "use default native compilers ", click "finish.
If the path to the generated directory does not exist, a prompt dialog box is displayed, as shown in. Click "yes.
For the first configuration, many red options will appear. Leave it alone and click "Configure" again.
This time, the red option is missing, indicating that there is no problem and the configuration is complete.
Click Generate.
After you see "generating done" at the bottom, it indicates that the source code project has been compiled.
Opencv2.4.9 sample Engineering Test
Open the folder under the generated directory path set in the previous step. A "solution" folder is displayed, which is automatically generated in the previous step. Double-click the folder.
Under the "h:/opencv/SOLUTION" path, we can see that there is a compiled vs2010 project file "opencv. sln ", double-click the file to open the project file in vs2010.
In the open "opencv" project, we can see 68 projects.
Right-click the opencv solution and choose generate solution.
Compilation takes a long time. My PC configuration is relatively good, but it takes about 2 minutes to compile. 62 projects are generated, and 0 projects fail. All projects are compiled successfully. Congratulations!
Next, you can view and compile each project. Will be supplemented later...
Learning the learning notes series of opencv (ii) source code compilation and sample projects