http://opencv.willowgarage.com/wiki/Visu alC%2B%2B_VS2008 OpenCV 2.1.0 with Visual Studio 2008 • These instructions were tested with Visual C++ 9.0 (as part ofVisual Studio 2008 Professional ). These instructions should work without modification with Visual Studio 2005 and 2003. Modifications may be necessary for Visual Studio Express editions. These instructions do not apply to Visual Studio 2010 which uses a different system for setting VC configuration. • There exists a short walkthrough video on YouTube at http://www.youtube.com/watch?v=9nPpa_WiArI Install OpenCV 1. Download the OpenCV 2.1.0 Windows installer from SourceForge - "OpenCV-2.1.0-win32-vs2008.exe". 2. Inst all it t o a fol der, say "C: \Prog ram Files\OpenCV \OpenCV210\" . This article will refer to this path as $openCVDir3. During in stallation check the o ption to a dd it to your Cu rrent User PATH Configure Visual Studio 1. Open VC++ Direc tori es confi gura tion: Too ls > Option s > Projects and Solutions > VC++ Directories 2. Choose "Show dire ctor ies for : Include files" 1. Add " $ope nCVDir\in clud e\op encv " 3. Choose "Show dire ctor ies for : Library files" 1. Add " $open CVDir\lib"
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
3. Open the "..." window to edit "Additional Dependencies" and oneach 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 tryrestarting Visual Studio and then doing a clean Rebuild.
OpenCV 1.x with Visual Studio 2003
• The set of instructions below is tested with Visual C++ 2003. Itwill also work with some modification under Visual C++ 6.0 andVisual C++ 2005, 2008 Express Edition.
To create your own OpenCV-based project in Visual Studio do the
following:
Linking DLLs:
• To permanantly include necessary dll files, add "C:\ProgramFiles\OpenCV\bin" to PATH by visiting Advanced tab in Systemof Windows (the locate of directory might be different).
• After the above steps done Developer Studio will create theproject folder (by default it has the same name as the
project), <project name>.vcproj file, Solution <projectname>.sln and, Three Source files:<project name>.cpp,stdafx.cpp and stdafx.h. StdAfx files are precompiled header files, which can be very useful if you want to reduce thecompilation time.
• For example, consider that we have created a new "Hello"Project. Open the Hello.cpp file, and include the OpenCV-related #include directives:
#include <cv.h>
#include <cxcore.h>
#include <highgui.h>
• Note that these should be included after stdafx.h or you mayget build errors.
• Now Type some OpenCV code, and Build the Solution bypressing the F7 Key. There should be linker errors.