Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set include path with environment variable value

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

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.

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?

like image 368
chmike Avatar asked Jul 17 '09 13:07

chmike


People also ask

How do I include a PATH variable?

To add a path to the PATH environment variableIn the System dialog box, click Advanced system settings. On the Advanced tab of the System Properties dialog box, click Environment Variables. In the System Variables box of the Environment Variables dialog box, scroll to Path and select it.

What does $path contain?

Introduction. A path is the name of a file's directory, which specifies a unique location in a file system. Whereas, the PATH system variable ( $PATH ), specifies a set of directories where executable programs are located. This allows software applications to access commonly executed programs.


3 Answers

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.

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

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

INCLUDEPATH += $$(MITK_INCLUDE_PATH)

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

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

like image 159
chmike Avatar answered Sep 17 '22 20:09

chmike


Have you tried adding:

INCLUDEPATH += <the path to the MITK headers>

in your project's .pro file ?

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

See QMake Manual

like image 41
Florian Avatar answered Sep 21 '22 20:09

Florian


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 )
like image 31
Caleb Huitt - cjhuitt Avatar answered Sep 20 '22 20:09

Caleb Huitt - cjhuitt