Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. qmake subdir deploy internal library
Qt 6.11 is out! See what's new in the release blog

qmake subdir deploy internal library

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 238 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.
  • M Offline
    M Offline
    MrShawn
    wrote on last edited by MrShawn
    #1

    Hello guys,

    I have a subdir project and have a kit to a remote linux device. I have set it up to build the application(s), deploy, and run on the remote device.

    In the applications I added internal libraries from the top level project and set up the dependency in the pro file as well. Basically to run the executable I also need the library files to be deployed as well, but I can only get it to deploy the executable, not the library files.

    My question is what do I need to write and in which .pro file I need to write it in (or anyhting else required) to get it to also deploy the .so files as well. Below is an example .pro for the subdir, application, and lib.

    top.pro

    TEMPLATE = subdirs
    
    SUBDIRS += \
        class1/class1.pro \
        class2/class2.pro \
        app/app.pro 
    
    app.depends = class1 class2
    
    CONFIG += ordered
    

    class1.pro

    QT -= gui
    QT += serialbus
    
    CONFIG += c++14 console
    CONFIG -= app_bundle
    
    TEMPLATE = lib
    DEFINES += CLASS1_LIBRARY
    
    target.path = /usr/lib
    INSTALLS += target
    
    # The following define makes your compiler emit warnings if you use
    # any Qt feature that has been marked deprecated (the exact warnings
    # depend on your compiler). Please consult the documentation of the
    # deprecated API in order to know how to port your code away from it.
    DEFINES += QT_DEPRECATED_WARNINGS
    
    # You can also make your code fail to compile if it uses deprecated APIs.
    # In order to do so, uncomment the following line.
    # You can also select to disable deprecated APIs only up to a certain version of Qt.
    #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
    
    SOURCES += \
            class1.cpp \
    
    
    HEADERS += \
            $$PWD/class1.h \
            class1_global.h
    
    # Default rules for deployment.
    qnx: target.path = /tmp/$${TARGET}/bin
    else: unix:!android: target.path = /opt/$${TARGET}/bin
    !isEmpty(target.path): INSTALLS += target
    

    app.pro

    QT -= gui
    QT += network
    
    CONFIG += c++14 console
    CONFIG -= app_bundle
    
    # The following define makes your compiler emit warnings if you use
    # any Qt feature that has been marked deprecated (the exact warnings
    # depend on your compiler). Please consult the documentation of the
    # deprecated API in order to know how to port your code away from it.
    DEFINES += QT_DEPRECATED_WARNINGS
    
    # You can also make your code fail to compile if it uses deprecated APIs.
    # In order to do so, uncomment the following line.
    # You can also select to disable deprecated APIs only up to a certain version of Qt.
    #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
    
    SOURCES += \
            main.cpp \
            server.cpp
    
    target.path = /usr/bin
    INSTALLS += target
    
    HEADERS += \
        server.h
    
    CONFIG(release, debug|release):DEFINES += QT_NO_DEBUG_OUTPUT
    
    unix:!macx: LIBS += -L$$OUT_PWD/../../class1/ -lclass1
    
    INCLUDEPATH += $$PWD/../../class1
    DEPENDPATH += $$PWD/../../class1
    
    unix:!macx: LIBS += -L$$OUT_PWD/../../class2/ -lclass2
    
    INCLUDEPATH += $$PWD/../../class2
    DEPENDPATH += $$PWD/../../class2
    

    I greatly simplified my .pro files /project structure but it should illustrate what I have and what I am trying to do. I believe the solution lies with doing something right with the target.path in the library .pro file or something similar but I am unsure.

    Thank you!

    1 Reply Last reply
    0
    • M Offline
      M Offline
      MrShawn
      wrote on last edited by
      #3

      @ChrisW67 Was a typo, I just tried to simplify for example here and made that mistake. In reality I have a lot of libs and apps.

      I did figure it out however here is the solution that needs to be put in the .pro files for the libraries.

      library.pro

      libraryFiles.path = /usr/lib
      
      CONFIG(debug, debug|release):libraryFiles.files = $$OUT_PWD/library.so $$OUT_PWD/library.so.1 $$OUT_PWD/library.so.1.0 $$OUT_PWD/library.so.1.0.0
      
      CONFIG(release, debug|release):libraryFiles.files = $$OUT_PWD/library.so $$OUT_PWD/library.so.1 $$OUT_PWD/libmooscommsbase.so.1.0 $$OUT_PWD/library.so.1.0.0
      
      INSTALLS += libraryFiles
      
      

      Basically now when I build/run any app, in the deployment step it will also make sure I have the library file in the target device's /usr/lib folder for the libraries that the application depends on. This way the application can find the shared library when it gets executed on the target device.

      1 Reply Last reply
      0
      • C Offline
        C Offline
        ChrisW67
        wrote on last edited by
        #2

        You do not seem to reference lib1.pro anywhere; only app.pro, class1.pro, and class2.pro

        1 Reply Last reply
        0
        • M Offline
          M Offline
          MrShawn
          wrote on last edited by
          #3

          @ChrisW67 Was a typo, I just tried to simplify for example here and made that mistake. In reality I have a lot of libs and apps.

          I did figure it out however here is the solution that needs to be put in the .pro files for the libraries.

          library.pro

          libraryFiles.path = /usr/lib
          
          CONFIG(debug, debug|release):libraryFiles.files = $$OUT_PWD/library.so $$OUT_PWD/library.so.1 $$OUT_PWD/library.so.1.0 $$OUT_PWD/library.so.1.0.0
          
          CONFIG(release, debug|release):libraryFiles.files = $$OUT_PWD/library.so $$OUT_PWD/library.so.1 $$OUT_PWD/libmooscommsbase.so.1.0 $$OUT_PWD/library.so.1.0.0
          
          INSTALLS += libraryFiles
          
          

          Basically now when I build/run any app, in the deployment step it will also make sure I have the library file in the target device's /usr/lib folder for the libraries that the application depends on. This way the application can find the shared library when it gets executed on the target device.

          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