OpenCV 2.1.0 with Visual Studio 2008
-
These instructions were tested with Visual C++ 9.0 (as part of Visual Studio 2008 Professional). These instructions do not apply to Visual Studio 2010 which uses a different system for setting VC configuration.
-
直接下载Download the OpenCV 2.1.0 Windows installer from SourceForge - "OpenCV-2.1.0-win32-vs2008.exe".免得编译的麻烦和时间空间。
- 安装到一个目录,例如"C:/OpenCV210, 创建环境变量 $openCVDir 。
- During installation check the option to add it to your Current User PATH
Configure Visual Studio
-
Open VC++ Directories configuration: Tools > Options > Projects and Solutions > VC++ Directories
- Choose "Show directories for: Include files" :包含文件
- Add "$(openCVDir)/include/opencv"
- Choose "Show directories for: Library files" : 库文件
- Add "$(openCVDir)/lib"
- Choose "Show directories for: Source files" :源文件
- Add "$(openCVDir)/src/cv"
- Add "$(openCVDir)/src/cvaux"
- Add "$(openCVDir)/src/cxcore"
- Add "$(openCVDir)/src/highgui"
Configure your Project
After you've created a project you'll need to add the OpenCV dependencies.
-
Open Project Properties: Project > %projectName% Properties...
-
Open Linker Input properties: Configuration Properties > Linker > Input
- Open the "..." window to edit "Additional Dependencies" and on each line put:
- "cv210.lib"
- "cxcore210.lib"
- "highgui210.lib"
- And any other lib file necessary for your project
- Your project should now build. If you get any errors try restarting Visual Studio and then doing a clean Rebuild