C ++ - 在Visual Studio 2010的属性表中使用环境变量 [英] C++ - Using environment variable in property sheet for Visual Studio 2010

查看:178
本文介绍了C ++ - 在Visual Studio 2010的属性表中使用环境变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想设置一个使用OpenCV的项目。所以基本上,我必须使用属性管理器从Visual Studio 2010添加一个新的属性表。

I want to set up a project which uses OpenCV. So basically, I have to add a new property sheet using the property manager from Visual Studio 2010.

基本上,我必须添加路径到我的 include lib 文件夹,以使OpenCV功能。我想把我的项目在一个git仓库,我不想每次更改属性表中的路径。有没有一种方法使用系统变量在我的属性表与OpenCV的构建文件夹的路径?如果存在这样做的方法,我可以直接从代码分配该变量的值吗?像 #define 或类似的作业?

Basically, I have to add the path to my include and lib folders in order to make OpenCV functional. I want to put my project in a git repository and I don't want to change the paths in my property sheets every time. Is there a way of using a system variable in my property sheet with the path to the build folder of OpenCV? If there exist a way of doing this, can I assign the value of that variable directly from the code? Like a #define or a similar assignment?

推荐答案

可用在属性设置中实际上是由Visual Studio添加的环境变量。如果您在用户配置文件中设置环境变量,您可以在属性表中使用它们,就像使用VS提供的内置宏一样。

The "macros" available in property settings are actually environment variables added by Visual Studio. If you set the environment variable in your user profile you can add use them in your property sheet the same way you use the "built-in" macros VS provides.

例如,我有一个网络硬盘驱动器,包含一个名为 LIBS 的文件夹,包含Boost,Google Test,Google Mock,Tiny XML和其他几个库。我把它作为驱动器字母 Z ,我有一个环境变量设置在我的用户配置文件 XTPLIBRARIES code> Z:\LIBS 。在我的属性表中,我已经配置了下面的包含路径。

For example, I have an networked hard drive with a folder called LIBS containing Boost, Google Test, Google Mock, Tiny XML and a few dozen other libraries. I mount it as drive letter Z and I have an environment variable set in my user profile called XTPLIBRARIES which points to Z:\LIBS. In my property sheet I've configured the include paths like below.


$(XTPLIBRARIES)\boost_1_53_0 \boost

$(XTPLIBRARIES)\gtest-1.6.0\include

$(XTPLIBRARIES)\tinyxml2

$(XTPLIBRARIES)\boost_1_53_0\boost
$(XTPLIBRARIES)\gtest-1.6.0\include
$(XTPLIBRARIES)\tinyxml2

现在任何时候我创建一个新项目,我只是添加属性表,一切正常工作 - 只要环境变量设置当然。

Now any time I create a new project I just add the property sheet and everything works as expected - as long as the environment variable is set of course.

这篇关于C ++ - 在Visual Studio 2010的属性表中使用环境变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆