Important: Please read the Qt Code of Conduct -

Debug/release folders with subdir template preventing from finding lib

  • Hello,
    i currently have a project with a structure like this :

    the issue is how to link the libmylib.a for my app.exe, ignoring the debug/release folders
    i'm programming with qtcreator on windows with mingw.
    but i need my code to be able to be compiled on command line on a linux machine, on windows i get this build structure :

    build_dir :

    • app
      • release
      • debug
    • mylib
      • release
        • libmylib.a
      • debug
        • libmylib.a

    and on linux, i got this :

    build dir :

    • app
    • mylib
      • libmylib.a

    so, from the point of view of, the path to libmylib.a changed depending on the system, preventing me to link correctly with the same .pro files on both systems.
    I have two questions :

    • is it possible to ignore the build / release directories (automatically append them depending on the build option) ?
    • is it possible on command line, to call qmake on a certain way to get the exact same structure qtcreatot generates on windows ?

  • This post is deleted!

  • @Anselme

    Hi and welcome to devnet

    With DESTDIR you can specify in each .pro where to place the result/target of the run. In you can specify the location for storing the lib and in you can use LIBS the location where to the libs.

  • That doesn't really answer any of my 2 questions, but I tried a workaround using DESTDIR, I STILL i don't know what to put as DESTDIR since i don't want an absolute path, and relative paths are relative to the build directory...

  • Hi,

    In project file:

    #configure var (path where the compiler is saving result)  DESTDIR
    win32-g++:CONFIG(release, debug|release): DESTDIR = $$OUT_PWD/release
    linux-g++:CONFIG(release, debug|release): DESTDIR = $$OUT_PWD
    win32-g++:CONFIG(debug, debug|release): DESTDIR = $$OUT_PWD/debug
    linux-g++:CONFIG(debug, debug|release): DESTDIR = $$OUT_PWD
    #configure var PATHCOPY
    win32-g++:PATHCOPY = C:/myfolder/lib
    linux-g++:PATHCOPY = /opt/myfolder/lib
    #after compilation will automatically copy to PATHCOPY

  • Finally fixed it, i used a .qmake.conf file to store the root directory in a shared variable, for those who are interested, here are my 3 .pro files :

    TEMPLATE = subdirs
    CONFIG += ordered c++11
    SUBDIRS = ircbot \
    myApp.depends = ircbot

    DESTDIR = $$lib_dir
    TARGET = mylib
    TEMPLATE = lib
    CONFIG += staticlib
    SOURCES += ...
    HEADERS += ...
    FORMS   += ...

    DESTDIR = $$bin_dir
    TARGET = myApp
    TEMPLATE = app
    LIBS += $$lib_dir/libmylib.a
    INCLUDEPATH += ../mylib
    SOURCES = ...
    HEADERS += ...
    FORMS   += ...

    and finally, the .qmake.conf file :


    this successfully creates this project structure :

    + a build directory anywhere i want