Using libraries with multiple kits
-
Hello.
I have a project that uses a static library, made by me. I include the library from my project's .pro file thus:
build_pass:CONFIG(debug, debug|release) {
LIBS += -L../StdFuncs/DebugQt
}build_pass:CONFIG(release, debug|release) {
LIBS += -L../StdFuncs/ReleaseQt
}LIBS += -lStdFuncs
You can see that there are debug and release versions of the library that are built into different directories. When I build this from the command line it works fine, under both Linux and Windows. If I import it into Qt Creator, and I disable the "shadow build" in project settings then it also works.
However then I cannot switch between compilers (I like to compile with MSVC 32 and 64 bit, plus GCC to catch all warnings) because everything is built into the same directory. So I turn on shadow build and now everything is built into separate directories such as "build-StdFuncs-Desktop_Qt_5_7_0_MSVC2013_32bit-Debug/DebugQt" so of course now the libraries are not found.
When I followed the instructions for adding an external static library using Qt Creator, it works, but ends up with these ugly hard coded paths in my .pro file:
win32: LIBS += -L$$PWD/../build-StdFuncs-Desktop_Qt_5_7_0_MSVC2013_32bit-Debug/DebugQt/ -lStdFuncs
Ugh. Not only is it ugly but it means that If I want to compile with both MSVC 2013 and MSVC 2015 for 32 bit or for 64 bit then I end up with all of these ugly hard coded paths in my .pro file which clash with one another.
So I figured there has to be a better way, such as a magic variable such as $$KIT_OUT that is changed when the .pro file is parsed to be changed to the name of the kit you are using. But I cannot find this anywhere. Actually I fought for this for ages until I found the "shadow copy" checkbox.
Is there a way to do something like this? qmake is so well done I can't believe that such an ugly architectural problem would have been missed by its designers.
-
Hello mate.
Unfortunately OUT_PWD is the output directory of the current project. So in the case where I am linking an executable with a library it is the directory of the executable. But what I want is the output directory of the dependent library. I have searched all through the documentation and tried everything but it seems that this is not supported.
I am going to raise a bug. Unless this functionality is well hidden, it is missing.
Thanks for the suggestion anyway.
-
Sorry, I thought you were using the
subdirs
template for your project. It's not the case, is it ? -
@SGaist said in Using libraries with multiple kits:
Sorry, I thought you were using the
subdirs
template for your project. It's not the case, is it ?No, I am using the two projects side by side on the same level. I investigated the subdirs template but to use that I would need to have a specially checked out version of my project that used a different layout. Anyway I got it working by turning off the shadow directory, although this seems quite a missing piece of functionality to me, so I also raised an issue in Jira. In here someone has given the same answer as you have and then closed the issue, so it seems that this use case simply isn't considered. :-/ Oh well.
-
Your use case matches rather this setup: external dependency that you build and install in a known place like for example
/usr/local
on *nix system.