12

I came across a lib missing problem in my app, it turns out that this might relate to my understanding of $$PWD and . in .pro file of qt project.

  1. So do $$PWD and . both mean the dir, which contains the .pro file OR the dir, which is generated by building process(like: ****-build-desktop-Qt_4_8_1_in_PATH__System__Debug). Or, they mean different things.

  2. in some variable declaration like OBJECTS_DIR = obj/Obj, it looks like that . means the generated dir. Whereas, in HEADERS += remoteclient.h ./RealPlay/realplay.h \, it looks like that . means the dir that contains .pro file.

  3. How about their meanings in LIBS and DESTDIR, etc. ?

Henry
  • 2,819
  • 3
  • 18
  • 33

1 Answers1

15

$$PWD means the dir where the current file (.pro or .pri) is.

It means the same in LIBS. I just used it like this in my project:

LIBS += -L$$PWD/deps/android -lopenal

. doesn't have any special meaning in the .pro file. It means the same thing as in Linux/Unix shell: the current working directory. If you use it in LIBS, it will most probably refer to the build directory where the link command is being run. . is not expanded. If you say -L. the linker will literally get -L.

In the case of HEADERS += remoteclient.h ./RealPlay/realplay.h \ qmake will treat these paths relative to $$PWD so it doesn't matter if there's . or not. HEADERS += $$PWD/remoteclient.h $$PWD/./RealPlay/realplay.h \ would be the effective search paths in this case. Otherwise out-of-source builds wouldn't work.

Note that . in the middle of a path doesn't do anything.

Steve Folly
  • 8,327
  • 9
  • 52
  • 63
juzzlin
  • 45,029
  • 5
  • 38
  • 50
  • so in case `OBJECTS_DIR = obj/Obj` , you mean it actually means `$$PWD/obj/Obj` ? But the truth is it's in the build dir, - namely - say `.../Linux32/****-build-desktop-Qt_4_8_1_in_PATH__System__Debug/obj/Obj` where the `.pro` file locates in `.../Linux32/QtCreator/`. I'm still a little confusing here – Henry Mar 02 '16 at 00:15
  • I didn't say anything about OBJECTS_DIR. It might be relative to the build dir :) – juzzlin Mar 02 '16 at 13:01