[Interest] Svar: Qt permanently broke on computer

Kai Köhne Kai.Koehne at qt.io
Wed Apr 28 08:23:14 CEST 2021

> Von: Interest <interest-bounces at qt-project.org> Im Auftrag von Jason H
> Betreff: Re: [Interest] Svar: Qt permanently broke on computer
> Good news everybody, I have partialyl figured it out, but I hope you can help me further.
> MYPROJ = ../phidget-spinner
> win32 {
>    INCLUDEPATH +=$$MYPROJ/libraries/phidget22-windevel/lib/c
> #this works:
>    LIBS +=-L$$PWD/../phidget-spinner/libraries/phidget22-windevel/lib/c/x64 -lphidget22
> #these breaks Qt (each):
>   LIBS +=-L$$MYPROJ/libraries/phidget22-windevel/lib/c/x64 -lphidget22
>   LIBS +=-L"$${MYPROJ}/libraries/phidget22-windevel/lib/c/x64" -lphidget22
>   LIBS +=-L$${MYPROJ}/libraries/phidget22-windevel/lib/c/x64 -lphidget22
> }
>Not sure why $$MYPROJ works for INCLUDEPATH but breaks the linker? 

You're probably using a shadow build directory (that is, build directory != source directory), which is the default of Qt Creator.

INCLUDEPATH is a qmake variable. qmake will see that it is a relative path, and make it relative to the build directory. That is, what's passed to the compiler isn't -I../phidget-spinner/libraries/phidget22-windevel/lib/c , but something like -Ibuild-myproject-5_15_msvc_2019_amd64-Debug/../myproject/phidget-spinner/libraries/phidget22-windevel/lib/c

Now for the library search path, LIBS is added (more or less) directly to the linker command line. And for the linker, the 'current working directory' is the build directory.

IIRC you can use LIBPATH to get the same effect as with INCLUDEPATH. Anyhow, the qmake documentation recommends using LIBS in the way you did... The easy fix (as you found out) is to use absolute paths here.

> If the link path is wrong I would expect it to fail the build, bot break Qt?

It's hard to say what happened for you. Maybe you had another version of your libraries registered in the environment, which were picked up instead?



More information about the Interest mailing list