Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does Qt add 'PWD' to libraries that are NOT referenced relatively?

Whenever I add a library in the .pro file of a Qt project (in Qt 5.2) it adds a $$PWD before the path of the libraries and include path. For example

INCLUDEPATH += $$PWD/C:/opencv/opencv-msvc2013/install/include

and

win32:CONFIG(release, debug|release): LIBS += -L$$PWD/C:/opencv/opencv-msvc2013/install/x64/vc12/lib/

My question is

  1. why does Qt start the path with the PWD (Present Working Directory) keyword if its providing an absolute path to the libraries? What logic/good programming practice is this convention following?
  2. And most importantly why it does not result in an error? How does Qt know when to search relative to a working directory and when not to? (Since both cases start with the PWD keyword)

PS : I removed the $$PWD keywords and my code worked just fine as well.

like image 781
user3079474 Avatar asked Feb 04 '26 20:02

user3079474


1 Answers

In case both the project and the library are in the same drive, that would not happen and the relative path is generated automatically. But on Windows if you add a library which is in another drive, it would add $$PWD followed by an absolute path.

This sounds like a bug and it has been reported here but it's still unresolved.

like image 184
Nejat Avatar answered Feb 06 '26 10:02

Nejat