Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. Debug/release folders with subdir template preventing from finding lib
QtWS25 Last Chance

Debug/release folders with subdir template preventing from finding lib

Scheduled Pinned Locked Moved Solved Qt Creator and other tools
qmakesubdirdebuglibrelease
6 Posts 3 Posters 3.9k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Anselme
    wrote on last edited by A Former User
    #1

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

    • project.pro
    • app
      • app.pro
    • mylib
      • mylib.pro

    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 ?
    K 1 Reply Last reply
    0
    • A Anselme

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

      • project.pro
      • app
        • app.pro
      • mylib
        • mylib.pro

      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 ?
      K Offline
      K Offline
      koahnig
      wrote on last edited by
      #2
      This post is deleted!
      1 Reply Last reply
      0
      • K Offline
        K Offline
        koahnig
        wrote on last edited by
        #3

        @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.

        1 Reply Last reply
        1
        • A Offline
          A Offline
          Anselme
          wrote on last edited by
          #4

          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...

          1 Reply Last reply
          0
          • R Offline
            R Offline
            ReinaldoJr
            wrote on last edited by
            #5

            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
            
            1 Reply Last reply
            1
            • A Offline
              A Offline
              Anselme
              wrote on last edited by
              #6

              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 :

              • bin
                • myApp.exe
              • lib
                • mylib.a
              • project.pro
              • .qmake.conf
              • myApp
                • myApp.pro
              • mylib
                • mylib.pro

              + a build directory anywhere i want

              1 Reply Last reply
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved