使用环境变量值设置包含路径 [英] Set include path with environment variable value

查看:54
本文介绍了使用环境变量值设置包含路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在尝试将 MITK 库与 Linux 上的 Qt 一起使用.

We are trying to use the MITK library with Qt on Linux.

不幸的是,MITK 没有安装功能,它也依赖于 ITK 和 VTK.所以我们最终得到了分散在许多目录中的头文件.

Unfortunately MITK has no install functionality and it also depends on ITK and VTK. So we end up with header files scattered in many directories.

我们想在环境变量中指定要添加到包含路径中的目录列表,如下所示:INCPATH+=$MITK_INCLUDE_PATH.但这似乎不起作用.

We would like to specify the list of directories to add in the include path in an environment variable like this : INCPATH+=$MITK_INCLUDE_PATH. But this doesn't seem to work.

我们怎样才能做到这一点?有没有更好的办法?

How could we achieve this? Is there a better way?

推荐答案

刚刚自己找到了解决方案.尽管我对 Aidos 和 cjhuitt 的回答表示赞赏,他们的回答让我走上了正轨并节省了我宝贵的时间.特别感谢 qmake 文档的链接.

Just found out the solution myself. Though I granted a point to Aidos and cjhuitt for their answers that put me on the right track and saved me valuable time. A special thanks for the link to the qmake documentation.

第一点是我应该修改 .pro 文件而不是摆弄扩展的构建参数.

The first point is that I should modify the .pro file and not fiddle with the extended build arguments.

要在处理 qmake 时获取环境变量的内容,应使用以下语法

To get the content of an environment variable when qmake is processed one should use the following syntax

INCLUDEPATH += $$(MITK_INCLUDE_PATH)

INCLUDEPATH += $$(MITK_INCLUDE_PATH)

请注意,要在处理 make 时获取环境变量的内容,应使用以下语法

Note that to get the content of an environment variable when make is processed one should use the following syntax

INCLUDEPATH += $(MITK_INCLUDE_PATH)

INCLUDEPATH += $(MITK_INCLUDE_PATH)

但是如果环境变量包含多个路径,这将不会产生相同的效果.那么第一种形式是优选的.

But this won't have the same effect if the environment variable contains multiple paths. The first form is then preferable.

环境变量中的路径必须用空格分隔,因为;无法识别.

Paths in the environment variable must be separated by spaces because the ; is not recognized.

如果路径包含空格,请在其周围加上引号.引号之间出现的空格将被 '\' 替换.

If a path contain spaces, put quotes around it. Spaces appearing between the quotes will be replaced by '\ '.

这篇关于使用环境变量值设置包含路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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