OpenCV source code compilation under the Windows platform

Source: Internet
Author: User

The official website of the OpenCV Library is http://opencv.org/. In the site can download the latest OpenCV for Windows, such as the current I download is Opencv-2.4.9.exe, double-click the file extracted to a directory, the extracted root directory for the OPENCV,OPENCV directory has 2 subdirectories, The build and Sources,build directories are stored in a compiled library, and the sources directory contains the source code. Below we will compile the source code in the sources directory.

You can see a CMakeLists.txt file in the sources directory, which is used to generate vs works with CMake.

Click Configure and generate respectively, the VS2008 is installed on my machine, so select VS2008.

Configuration files such as the VS solution can then be seen in the Cmake-bin directory.

Double-click OpenCV.sln to open VS, the project is shown as follows:

Press F7 to compile , then you can go to the toilet, drink tea or something, (^_^) ∠※

Came back and found that there was a project compile error:


1>------Started Build: project: Opencv_python, config: Debug Win32------1> is linking ... 1>link:fatal error LNK1104: Can't open File "Python27_d.lib"
Online Search for the relevant answers are: http://blog.csdn.net/loonger_leon/article/details/5862150

I can't use Python for the time being, so I don't care about it for the moment.

Finally, you can install the OpenCV library into the Cmake-bin/install directory by right- creating the Install project. After you write the OPENCV application, you can reference the library file and the header file in the Cmake-bin/install directory.

To facilitate the application's reference, we also need to set environment variables here. Execute at the command line:

Setx-m Opencv_dir F:\OPENCV_CODE\sources\cmake-bin\install

The environment variable for the OPENCV library path is set, which can be queried using the SET command

Opencv_dir=f:\opencv_code\sources\cmake-bin\install

To facilitate dynamic loading, we need to place the loaded dynamic link library in the PATH environment variable.


Otherwise it will need to be placed in the same directory as the executable, an application is OK, if more than one time each will have to copy the dynamic library to the same directory as the executable file.


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.