VS2010+Opencv配置——不用每个工程单独配置

1.(WIN7)在目录C:\Users\zheng2\AppData\Local\Microsoft\MSBuild\v4.0下找到并替换以下文件
Microsoft.Cpp.Win32.user.props,win7下此文件可能是没内容的(只有XML头),备份原文件,用下面内容替换


内容如下:
 
 
     
       C:\Program Files\MicrosoftSDKs\Windows\v7.0A\bin;$(ExecutablePath) 
       C:\dev\opencv\build\include;C:\dev\opencv\build\include\opencv;C:\dev\opencv\build\include\opencv2;$(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(FrameworkSDKDir)\include;$(WindowsSdkDir)include;$(IncludePath) 
       $(ReferencePath) 
       C:\dev\opencv\build\x86\vc10\lib;C:\dev\opencv\build\x86\vc10\staticlib;$(VCInstallDir)lib;$(VCInstallDir)atlmfc\lib;$(WindowsSdkDir)lib;$(FrameworkSDKDir)\lib;$(LibraryPath) 
       $(SourcePath)  
       $(ExcludePath) 
   
 
 


根据你的openCV路径,修改上面路径,我这里是用绝对路径写的。这一步是一次性的工作,一劳永逸。


2.重启VS2010,现在新建的VC项目都自动添加了openCV的路径
在程序文件的include后面添加如下代码将库引入即可,注意这里的版本号,改成你自己的openCV版本
#pragma comment( lib, "opencv_highgui242d.lib" ) 
#pragma comment( lib, "opencv_core242d.lib" ) 
#pragma comment( lib, "opencv_ml242d.lib" ) 
#pragma comment( lib, "opencv_imgproc242d.lib" )

你可能感兴趣的:(opencv,vs2010)