设置包含环境变量值的路径

时间:2022-01-17 11:12:44

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

我们正在尝试在Linux上使用带有Qt的MITK库。

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.

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

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.

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

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

我们怎么能实现这个目标?有没有更好的办法?

4 个解决方案

#1


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.

刚刚找到了解决方案。虽然我向Aidos和cjhuitt授予了他们的答案,这些答案让我走上正轨并为我节省了宝贵的时间。特别感谢qmake文档的链接。

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

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

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

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

INCLUDEPATH += $$(MITK_INCLUDE_PATH)

INCLUDEPATH + = $$(MITK_INCLUDE_PATH)

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

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

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 '\ '.

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

#2


Have you tried adding:

你试过添加:

INCLUDEPATH += <the path to the MITK headers>

INCLUDEPATH + = 标题的路径>

in your project's .pro file ?

在你的项目的.pro文件中?

And possibly you'll also need to edit LIBS and DEPENDPATH.

您可能还需要编辑LIBS和DEPENDPATH。

See QMake Manual

请参阅QMake手册

#3


I think there's a cleaner way to do this, but I can't remember. Anyway, you could use the system directive:

我认为有一个更清洁的方法,但我不记得了。无论如何,您可以使用系统指令:

INCLUDEPATH += $$system( echo $MITK_INCLUDE_PATH )

You may also want to add it to depend path:

您可能还想将其添加到依赖路径:

DEPENDPATH += $$system( echo $MITK_INCLUDE_PATH )

#4


i dont know but maybe you can try to write like

我不知道,但也许你可以试着写

INCPATH+=%MITK_INCLUDE_PATH%

in windows, generally it is like that..

在windows中,一般就是这样..

but i did not try.

但我没试过。

#1


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.

刚刚找到了解决方案。虽然我向Aidos和cjhuitt授予了他们的答案,这些答案让我走上正轨并为我节省了宝贵的时间。特别感谢qmake文档的链接。

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

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

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

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

INCLUDEPATH += $$(MITK_INCLUDE_PATH)

INCLUDEPATH + = $$(MITK_INCLUDE_PATH)

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

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

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 '\ '.

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

#2


Have you tried adding:

你试过添加:

INCLUDEPATH += <the path to the MITK headers>

INCLUDEPATH + = 标题的路径>

in your project's .pro file ?

在你的项目的.pro文件中?

And possibly you'll also need to edit LIBS and DEPENDPATH.

您可能还需要编辑LIBS和DEPENDPATH。

See QMake Manual

请参阅QMake手册

#3


I think there's a cleaner way to do this, but I can't remember. Anyway, you could use the system directive:

我认为有一个更清洁的方法,但我不记得了。无论如何,您可以使用系统指令:

INCLUDEPATH += $$system( echo $MITK_INCLUDE_PATH )

You may also want to add it to depend path:

您可能还想将其添加到依赖路径:

DEPENDPATH += $$system( echo $MITK_INCLUDE_PATH )

#4


i dont know but maybe you can try to write like

我不知道,但也许你可以试着写

INCPATH+=%MITK_INCLUDE_PATH%

in windows, generally it is like that..

在windows中,一般就是这样..

but i did not try.

但我没试过。