OpenCV 2.1.0 with Visual Studio 2008

Install OpenCV

  1. Download the OpenCV 2.1.0 Windows installer from SourceForge - "OpenCV-2.1.0-win32-vs2008.exe".

  2. Install it to a folder (without any spaces in it), say "C:\OpenCV2.1\". This article will refer to this path as $openCVDir
  3. During installation, enable the option "Add OpenCV to the system PATH for all users".

Configure Visual Studio

  1. Open VC++ Directories configuration: Tools > Options > Projects and Solutions > VC++ Directories

  2. Choose "Show directories for: Include files"
    1. Add "$openCVDir\include\opencv"
  3. Choose "Show directories for: Library files"
    1. Add "$openCVDir\lib"
  4. Choose "Show directories for: Source files"
    1. Add "$openCVDir\src\cv"
    2. Add "$openCVDir\src\cvaux"
    3. Add "$openCVDir\src\cxcore"
    4. Add "$openCVDir\src\highgui"

Configure your Project

After you've created a project you'll need to add the OpenCV dependencies.

  1. Open Project Properties: Project > %projectName% Properties...

  2. Open Linker Input properties: Configuration Properties > Linker > Input

  3. Open the "..." window to edit "Additional Dependencies" and on each line put:
    1. "cv210.lib"
    2. "cxcore210.lib"
    3. "highgui210.lib"
    4. And any other lib file necessary for your project
  4. Your project should now build. If you get any errors try restarting Visual Studio and then doing a clean Rebuild.

OpenCV 1.x with Visual Studio 2003


To create your own OpenCV-based project in Visual Studio do the following:

Linking DLLs:

Customize Global Options:

"C:\OpenCV1.0\lib"

Options_Library.jpg

        "C:\OpenCV1.0\cv\include"
        "C:\OpenCV1.0\cxcore\include"
        "C:\OpenCV1.0\otherlibs\highgui"
        "C:\OpenCV1.0\cvaux\include"
        "C:\OpenCV1.0\otherlibs\_graphics\include"

Options_Include.jpg

        "C:\OpenCV1.0\cv\src"
        "C:\OpenCV1.0\cxcore\src"
        "C:\OpenCV1.0\cvaux\src"
        "C:\OpenCV1.0\otherlibs\highgui"
        "C:\OpenCV1.0\otherlibs\_graphics\src"

Options_Source.jpg

Create New Project:

Win32Console.jpg

AppWizard.jpg

                    #include <cv.h>
                    #include <cxcore.h>
                    #include <highgui.h>

AdditionalDependencies.jpg

Compiling.jpg .

If you have any queries regarding this, try posting at OpenCV Yahoo! Groups.


OpenCVWiki: VisualC++_VS2008 (last edited 2010-08-02 01:18:46 by ShervinEmami)