VS2013怎么配置opencv才能不用每次都重新配置一遍
1个回答
2016-09-12 · 做真实的自己 用良心做教育
千锋教育
千锋教育专注HTML5大前端、JavaEE、Python、人工智能、UI&UE、云计算、全栈软件测试、大数据、物联网+嵌入式、Unity游戏开发、网络安全、互联网营销、Go语言等培训教育。
向TA提问
关注
展开全部
请认准属性表,一次编写,到处使用,系统环境变量你都不需要设定,所有设定都写在属性表文件中,用的时候在vs里导入属性表。如果要切换opencv版本,只修改opencv编译输出目录就可以了。
比如OpenCV3.0版的,可以命名为opencv300.props:
<?xml version="1.0" encoding="utf-8"?>
<!--
OpenCV 3.0.0属性表文件
不用单独配置环境变量OpenCV
也不用单独在系统PATH上添加OpenCV可执行路径
只需要在VisualStudio-"菜单"-"视图"-"属性管理器"中添加现有属性表,添加本文件
使用前请将下面的OpenCVRoot修改为你的OpenCV编译输出目录
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ImportGroup Label="PropertySheets" />
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<!-- 请把OpenCVRoot属性的值替换为你的OpenCV编译输出的目标目录,它包含x64、x86这样的子目录 -->
<OpenCVRoot>D:\lib\opencv300\build</OpenCVRoot>
<!-- 指定INCLUDE路径-->
<IncludePath>$(OpenCVRoot)\include;$(IncludePath)</IncludePath>
<!-- 指定链接所需lib目录-->
<LibraryPath Condition="'$(Platform)'=='Win32'">$(OpenCVRoot)\x86\vc12\lib;$(LibraryPath)</LibraryPath>
<LibraryPath Condition="'$(Platform)'=='X64'">$(OpenCVRoot)\x64\vc12\lib;$(LibraryPath)</LibraryPath>
<!-- 保证系统处于Debug模式时,可以使用相对路径读取源代码目录下的文件,比如"lena.jpg"而不必是"d:/work/test/test/lena.jpg" -->
<LocalDebuggerWorkingDirectory>$(ProjectDir)</LocalDebuggerWorkingDirectory>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
<!-- 让系统PATH临时包含指定的dll目录 -->
<LocalDebuggerEnvironment Condition="'$(Platform)'=='Win32'">PATH=%PATH%;$(OpenCVRoot)\x86\vc12\bin</LocalDebuggerEnvironment>
<LocalDebuggerEnvironment Condition="'$(Platform)'=='X64'">PATH=%PATH%;$(OpenCVRoot)\x64\vc12\bin</LocalDebuggerEnvironment>
</PropertyGroup>
<!-- 以下是程序需要加载的lib文件。-->
<ItemDefinitionGroup>
<Link Condition="'$(Configuration)'=='Debug'">
<AdditionalDependencies>opencv_ts300d.lib;opencv_world300d.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<Link Condition="'$(Configuration)'=='Release'">
<AdditionalDependencies>opencv_ts300.lib;opencv_world300.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemGroup />
</Project>
比如OpenCV3.0版的,可以命名为opencv300.props:
<?xml version="1.0" encoding="utf-8"?>
<!--
OpenCV 3.0.0属性表文件
不用单独配置环境变量OpenCV
也不用单独在系统PATH上添加OpenCV可执行路径
只需要在VisualStudio-"菜单"-"视图"-"属性管理器"中添加现有属性表,添加本文件
使用前请将下面的OpenCVRoot修改为你的OpenCV编译输出目录
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ImportGroup Label="PropertySheets" />
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<!-- 请把OpenCVRoot属性的值替换为你的OpenCV编译输出的目标目录,它包含x64、x86这样的子目录 -->
<OpenCVRoot>D:\lib\opencv300\build</OpenCVRoot>
<!-- 指定INCLUDE路径-->
<IncludePath>$(OpenCVRoot)\include;$(IncludePath)</IncludePath>
<!-- 指定链接所需lib目录-->
<LibraryPath Condition="'$(Platform)'=='Win32'">$(OpenCVRoot)\x86\vc12\lib;$(LibraryPath)</LibraryPath>
<LibraryPath Condition="'$(Platform)'=='X64'">$(OpenCVRoot)\x64\vc12\lib;$(LibraryPath)</LibraryPath>
<!-- 保证系统处于Debug模式时,可以使用相对路径读取源代码目录下的文件,比如"lena.jpg"而不必是"d:/work/test/test/lena.jpg" -->
<LocalDebuggerWorkingDirectory>$(ProjectDir)</LocalDebuggerWorkingDirectory>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
<!-- 让系统PATH临时包含指定的dll目录 -->
<LocalDebuggerEnvironment Condition="'$(Platform)'=='Win32'">PATH=%PATH%;$(OpenCVRoot)\x86\vc12\bin</LocalDebuggerEnvironment>
<LocalDebuggerEnvironment Condition="'$(Platform)'=='X64'">PATH=%PATH%;$(OpenCVRoot)\x64\vc12\bin</LocalDebuggerEnvironment>
</PropertyGroup>
<!-- 以下是程序需要加载的lib文件。-->
<ItemDefinitionGroup>
<Link Condition="'$(Configuration)'=='Debug'">
<AdditionalDependencies>opencv_ts300d.lib;opencv_world300d.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<Link Condition="'$(Configuration)'=='Release'">
<AdditionalDependencies>opencv_ts300.lib;opencv_world300.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemGroup />
</Project>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询