Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can you use environmental variables in qt creator?

So I use a bunch of libraries in the code I'm currently working in. Right now I include them by doing things like win32:LIBS += "C:/my/location/Tools/libcurl/trunk/lib/Debug/curllib.lib". However, I have an environmental variable that defined %TOOLS% as C:/my/location/Tools/. I tried to simply change my include to win32:LIBS += "%TOOLS%libcurl/trunk/lib/Debug/curllib.lib", but it could not find the files. I looked online and this should be doable. Am I missing something simple, like a way to tell Qt creator to look at window's environmental variables?

Thanks!

like image 637
user3175137 Avatar asked Jun 17 '14 05:06

user3175137


2 Answers

To get the content of an environment variable when qmake is processed, you can use the following :

win32:LIBS += $$(TOOLS)/libcurl/trunk/lib/Debug/curllib.lib

TOOLS should be an environment variable set to C:/my/location/Tools.

But you don't necessarily need an environment variable for this. You can simple define a variable in your .pro file :

TOOLS="C:/my/location/Tools"

And use it's value by prefixing it with $$ :

win32:LIBS += $$TOOLS/libcurl/trunk/lib/Debug/curllib.lib
like image 183
Nejat Avatar answered Nov 15 '22 08:11

Nejat


Try the following:

$$VAR => QMake variable's value at the time qmake is run
$${VAR} => QMake variable's value at time qmake is run (subtle difference)
$(VAR) => Contents of an Environment variable at the time Makefile (not qmake) is run

In your Case: $$(TOOLS) return the Path you need.

like image 42
Matthias Avatar answered Nov 15 '22 07:11

Matthias