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 app.pro, 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 ?

  • Moderators

    This post is deleted!

  • Moderators

    @Anselme

    Hi and welcome to devnet

    With DESTDIR you can specify in each .pro where to place the result/target of the run. In mylib.pro you can specify the location for storing the lib and in app.pro 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
    QMAKE_POST_LINK = $${QMAKE_COPY} $$DESTDIR/$$TARGET $$PATHCOPY/$$TARGET


  • 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 :

    project.pro

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

    mylib.pro

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

    myApp.pro

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

    and finally, the .qmake.conf file :

    lib_dir=$$PWD/lib
    bin_dir=$$PWD/bin
    

    this successfully creates this project structure :

    + a build directory anywhere i want


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.