How to configue OpenCV in Visual Studio

tested on OpenCV 1.0 with Visual Studio 2005
tested on OpenCV 0.9 with Visual Studio 2003

If you need DXSDK support, please follow Section 2. If not, Section 1 is enough.

update 2009-1-8: for new versions of OpenCV, just adding path to VS is enough, no need to compile any more.  So, please just do Section 1 step 3~5, that’s all.

Section 1 (Configure without DXSDK)

  1. Open “C:\Program Files\OpenCV\_make\opencv.sln“.
    NOTE: @line 1138 in OpenCV file cvaux –> include –> external –> cvaux.h, there is an syntax error. change “/” to “*/“.
  2. Build solution with both debug and release configuration. (recommond to use “Build->batch build“). If u encounter any errors, u can try to remove all files in “C:\Program Files\OpenCV\_temp” and build again.
  3. Open visual c++, add following path to “Tools–>Options–>Projects–>VC++ Directories–>Include files“:
    C:\Program Files\OpenCV\cv\include
    C:\Program Files\OpenCV\otherlibs\highgui
    C:\Program Files\OpenCV\cxcore\include
    C:\Program Files\OpenCV\otherlibs\cvcam\include
  4. Add “C:\Program Files\OpenCV\lib” to “Tools–>Options–>Projects–>VC++ Directories–>Library files
  5. When create a new project,
    add following to “Project–>Properties–>LinkeràInput–>Additional dependencies
    (debug) cvd.lib cxcored.lib highguid.lib cvauxd.lib
    (release) cv.lib highgui.lib cvaux.lib cxcore.lib

Section 2 (Configure with DXSDK)

  1. Download OpenCV default installation dir is C:\Program Files\OpenCVDownload Directx SDK default installation dir is C:\DXSDK
  2. open
    C:\DXSDK\samples\C++\DirectShow
    \BaseClasses\baseclasses.sln
    build it using both debug and release configuration.
    copy ” strmbasd.lib & strmbase.libC:\DXSDK\lib.
  3. open visual c++, add following path to “Tools–>Options–>Projects–>VC++ Directories–>Library files -> Include files“:
    C:\DXSDK\Include
    C:\DXSDK\Samples\C++\Common\Include
    C:\DXSDK\Samples\C++\DirectShow\BaseClasses

    add C:\DXSDK\lib to “Tools–>Options–>Projects–>VC++ Directories–>Library files -> Library Files
  4. build “C:\Program Files\OpenCV\_make\opencv.sln” using both debug and release configuration. (recommond to use “Build->batch build“).if u encounter some builder errors, u can remove all files in “C:\Program Files\OpenCV\_temp” and build again.
  5. NOTE: @line 1138 in OpenCV file cvaux –> include –> external –> cvaux.h, there is an syntax error. change “/” to “*/“.
  6. build “C:\Program Files\OpenCV\_make\opencv_directshow.sln” using both debug and release configuration.(recommond to use “Build->batch build“).
  7. open visual c++, add following path to “Tools–>Options–>Projects–>VC++ Directories–>Include files“:
    C:\Program Files\OpenCV\cv\include
    C:\Program Files\OpenCV\otherlibs\highgui
    C:\Program Files\OpenCV\cxcore\include
    C:\Program Files\OpenCV\otherlibs\cvcam\include
  8. add “C:\Program Files\OpenCV\lib” to “Tools–>Options–>Projects–>VC++ Directories–>Library files -> Library Files
  9. when create a new project,
    add following to “Project–>Properties–>Linker->Input–>Additional dependencies
    (debug) cvd.lib cxcored.lib highguid.lib cvauxd.lib
    (release) cv.lib highgui.lib cvaux.lib cxcore.lib

Reference:
LIHAO,
http://spaces.msn.com/members/meteorash/Blog/cns!1pQBr1bgHmU1smFBpCpoUZ4A!105.entry

Related Post

  • No Related Posts
  1. Anonymous
    June 26th, 2007 | 6:07 am

    thanks,
    the additional dependencies fixed my issue.

  2. inspiraty
    August 18th, 2007 | 12:27 am

    多谢,解决了我的燃眉之急。。^^

  3. August 8th, 2009 | 2:24 pm

    [...] has been quite a while since last time I post a howto of configuring OpenCV in Visual Studio. The post got a lot of attention and comments. As the the configuring has become simpler, the post [...]