现在的位置: 首页 > 综合 > 正文

VS2010 C++目录配置(zz)

2013年06月08日 ⁄ 综合 ⁄ 共 2527字 ⁄ 字号 评论关闭

zz: http://blog.csdn.net/stone_sky/article/details/7578727

 VS2010 C++目录配置


        用过Visual Studio 2010的同学都知道,VS2010和VC 6.0以及其他VisualStudio版本不同,VS2010中C++的目录我们只能在单独的项目中配置。所有的项目有一个总的C++头文件、库文件目录配置。

 

        如果我们要添加一个很常用的Include目录,而我们又非得每个项目中自己动手填写,是不是很费劲呢?所以我们找到了一个很好的解决方案,使得一次配置目录,在以后的工程中不必自己填写了。

 

         我们首先找到这个总的配置文件所在目录:

         XP下:

[html] view
plain
copy

  1. C:\Documents andSettings\[User_Name]\Local Settings\ApplicationData\Microsoft\MSBuild\v4.0\Microsoft.Cpp.Win32.user.props  

         Win7/Vista下:

[html] view
plain
copy

  1. C:\Users\[User_Name]\AppData\Local\Microsoft\MSBuild\v4.0\Microsoft.Cpp.Win32.user.props  

其中“[User_Name]”是你当前登陆用户的用户名。这个配置文件都是以XML的格式组织的,所以我们用记事本可以直接打开。最原始的文件如下:

[html] view
plain
copy

  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <Project DefaultTargets="Build"ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">  
  3.   <PropertyGroup>  
  4.    <ExecutablePath>C:\Program Files\MicrosoftSDKs\Windows\v7.0A\bin;$(ExecutablePath)</ExecutablePath>  
  5.    <IncludePath>C:\Program Files\MicrosoftSDKs\Windows\v7.0A\Include; $(IncludePath)</IncludePath>  
  6.     <ReferencePath>$(ReferencePath)</ReferencePath>  
  7.     <LibraryPath>C:\ProgramFiles\Microsoft SDKs\Windows\v7.0A\Lib; $(LibraryPath)</LibraryPath>  
  8.    <SourcePath>$(SourcePath)</SourcePath>  
  9.    <ExcludePath>$(ExcludePath)</ExcludePath>  
  10.   </PropertyGroup>  
  11. </Project>  

现在比如我们有一个Direct3D的库,库安装目录如下:

[html] view
plain
copy

  1. D:\Program_Tools\Direct3D_Lib_2010  

对应的头文件件目录如下:

[html] view
plain
copy

  1. D:\Program_Tools\Direct3D_Lib_2010\Include  

对应的库目录如下:

[html] view
plain
copy

  1. D:\Program_Tools\Direct3D_Lib_2010\Lib\x86  

我们把这两个目录直接加到<IncludePath>和<LibraryPath>两个元素内。那么我们的配置文件如下:

[html] view
plain
copy

  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <Project DefaultTargets="Build"ToolsVersion="4.0"xmlns="http://schemas.microsoft.com/developer/msbuild/2003">  
  3.   <PropertyGroup>  
  4.    <ExecutablePath>C:\Program Files\MicrosoftSDKs\Windows\v7.0A\bin;$(ExecutablePath)</ExecutablePath>  
  5.    <IncludePath>C:\Program Files\MicrosoftSDKs\Windows\v7.0A\Include; D:\Program_Tools\Direct3D_Lib_2010\Include;$(IncludePath)</IncludePath>  
  6.    <ReferencePath>$(ReferencePath)</ReferencePath>  
  7.     <LibraryPath>C:\ProgramFiles\Microsoft SDKs\Windows\v7.0A\Lib; D:\Program_Tools\Direct3D_Lib_2010\Lib\x86  
  8. ;$(LibraryPath)</LibraryPath>  
  9.    <SourcePath>$(SourcePath)</SourcePath>  
  10.    <ExcludePath>$(ExcludePath)</ExcludePath>  
  11.   </PropertyGroup>  
  12. </Project>  

当然别忘了各个目录之间用英文的“;”分隔开来。由于我平常可能使用Python、Lua和Direct3D的开发,所以在我的VS2010中查看时,变成了下面这样:


Include


库目录如下:




       我们可以看到,灰色部分为VS2010缺省的配置。通过这样的配置,使得我们所有的项目都共享相同的库目录,也就解决了频繁为每一个项目配置目录带来的问题。

抱歉!评论已关闭.