I start a programm which includes a library (IDA) in
/home/MYUSERNAME/EB/IDA/Earlybite/
The library IDA has two folders:
/home/MYUSERNAME/EB/IDA/IDA/Includes/ (for h-file)
/home/MYUSERNAME/EB/IDA/IDA/Libs/ (for so-files)
This is the linking which works:
LIBS += -L$$PWD/../IDA/Libs/ -Wl,-rpath=$$PWD/../IDA/Libs/ -lIDA -ldl -lpthread -lrt
INCLUDEPATH += $$PWD/../IDA/Includes/
The problem is that PWD only shows the path in which Earlybite starts. In this case
/home/MYUSERNAME/EB/IDA/Earlybite/
, but if the programm starts e.g. in /home/MYUSERNAME/EB/IDA/
...the linking will not work.
So I tried to link with the HOME environment variable. E.g.
LIBS += -L$$HOME/EB/IDA/IDA/Libs/ -Wl,-rpath=$$HOME/EB/IDA/IDA/Libs/ -lIDA -ldl -lpthread -lrt
INCLUDEPATH += $$HOME/EB/IDA/IDA/Includes/
But this do not work.
I also tried
LIBS += -L/home/$$USER/EB/IDA/IDA/Libs/ -Wl,-rpath=/home/$$USER/EB/IDA/IDA/Libs/ -lIDA -ldl -lpthread -lrt
INCLUDEPATH += /home/$$USER/EB/IDA/IDA/Includes/
But this do not work, too. (I've also tried every try with a single $ and with two $ symbols...)
Edit: I just remembered that you can use $$(HOME)
which will read environment variable during qmake execution, so you just need to add ()
around HOME. Using $_PRO_FILE_PWD_
is still a good practice, but the last options is a workaround rather than straightforward solution I think.
You can try and use $$_PRO_FILE_PWD_
, this variable points to .pro
file location, and create path relative to project file. Also check qmake Variables for additional references.
Or you can do:
HOME = $$system(echo $HOME)
message($$HOME)
LIBS += -L$$HOME ...
About $$system
link