Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Qt project with custom shared library cross compile Qt
Forum Update on Monday, May 27th 2025

Qt project with custom shared library cross compile Qt

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
2 Posts 2 Posters 832 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.
  • D Offline
    D Offline
    drewpol
    wrote on 17 Mar 2018, 16:52 last edited by
    #1

    I built Qt 5.9.4 for cross-compile on Raspberry Pi 3. Everything works fine with test applications. My problem is following:

    Created static library in Qt Creator which is named SlaveDeviceModels. I deployed this library to raspberry and run this command on rpi:

    export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/pi/Documents/QtProjectsTests/SmartHomeServer
    

    Then I created console application project which is named SmartHomeServer and added to this project external library SlaveDeviceModels. Then I tried to run this application through Qt Creator but I get error:

    /home/pi/Documents/QtProjectsTests/SmartHomeServer/SmartHomeServer: error while loading shared libraries: libSlaveDeviceModels.so.1: cannot open shared object file: No such file or directory
    Application finished with exit code 127.
    

    So I go to rpi folder and it looks following:

    pi@raspberrypi:~/Documents/QtProjectsTests/SmartHomeServer $ ls -l
    total 3048
    -rwxr-xr-x 1 pi pi 2122400 Mar 17 14:10 SmartHomeServer
    -rw-r--r-- 1 pi pi    9006 Mar 17 14:04 SmartHomeServer.log
    lrwxrwxrwx 1 pi pi      29 Mar 17 13:28 libSlaveDeviceModels.so -> libSlaveDeviceModels.so.1.0.0
    lrwxrwxrwx 1 pi pi      29 Mar 17 13:28 libSlaveDeviceModels.so.1 -> libSlaveDeviceModels.so.1.0.0
    lrwxrwxrwx 1 pi pi      29 Mar 17 13:28 libSlaveDeviceModels.so.1.0 -> libSlaveDeviceModels.so.1.0.0
    -rwxr-xr-x 1 pi pi  980428 Mar 17 13:28 libSlaveDeviceModels.so.1.0.0
    

    Then I tried to run this app by ./SmartHomeServer and it worked fine. It started.

    Only problem is when I'm trying to start SmartHomeServer from Qt Creator on my local computer (cross-compile). Does anyone can help me where might be problem. Maybe missing settings in Qt Creator?

    This is my SmartHomeServer.pro file:

    QT += core
    QT -= gui
    
    CONFIG += c++11
    
    TARGET = SmartHomeServer
    CONFIG += console
    CONFIG -= app_bundle
    
    TEMPLATE = app
    
    SOURCES += main.cpp
    
    # The following define makes your compiler emit warnings if you use
    # any feature of Qt which as 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 you use 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
    
    # Default rules for deployment.
    target.path = /home/pi/Documents/QtProjectsTests/SmartHomeServer
    INSTALLS += target
    
    # here are included my headers
    INCLUDEPATH += $$PWD/../SlaveDeviceModels
    
    # I tried do something like that
    #LIBS += -L/home/pi/Documents/QtProjectsTests/SmartHomeServe -lSlaveDeviceModels
    
    # that are default lines added by qt creator
    unix:!macx: LIBS += -L$$PWD/../build-SlaveDeviceModels-Raspberry_Pi_3_Kit-Debug/ -lSlaveDeviceModels
    INCLUDEPATH += $$PWD/../build-SlaveDeviceModels-Raspberry_Pi_3_Kit-Debug
    DEPENDPATH += $$PWD/../build-SlaveDeviceModels-Raspberry_Pi_3_Kit-Debug
    
    K 1 Reply Last reply 17 Mar 2018, 17:46
    0
    • D drewpol
      17 Mar 2018, 16:52

      I built Qt 5.9.4 for cross-compile on Raspberry Pi 3. Everything works fine with test applications. My problem is following:

      Created static library in Qt Creator which is named SlaveDeviceModels. I deployed this library to raspberry and run this command on rpi:

      export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/pi/Documents/QtProjectsTests/SmartHomeServer
      

      Then I created console application project which is named SmartHomeServer and added to this project external library SlaveDeviceModels. Then I tried to run this application through Qt Creator but I get error:

      /home/pi/Documents/QtProjectsTests/SmartHomeServer/SmartHomeServer: error while loading shared libraries: libSlaveDeviceModels.so.1: cannot open shared object file: No such file or directory
      Application finished with exit code 127.
      

      So I go to rpi folder and it looks following:

      pi@raspberrypi:~/Documents/QtProjectsTests/SmartHomeServer $ ls -l
      total 3048
      -rwxr-xr-x 1 pi pi 2122400 Mar 17 14:10 SmartHomeServer
      -rw-r--r-- 1 pi pi    9006 Mar 17 14:04 SmartHomeServer.log
      lrwxrwxrwx 1 pi pi      29 Mar 17 13:28 libSlaveDeviceModels.so -> libSlaveDeviceModels.so.1.0.0
      lrwxrwxrwx 1 pi pi      29 Mar 17 13:28 libSlaveDeviceModels.so.1 -> libSlaveDeviceModels.so.1.0.0
      lrwxrwxrwx 1 pi pi      29 Mar 17 13:28 libSlaveDeviceModels.so.1.0 -> libSlaveDeviceModels.so.1.0.0
      -rwxr-xr-x 1 pi pi  980428 Mar 17 13:28 libSlaveDeviceModels.so.1.0.0
      

      Then I tried to run this app by ./SmartHomeServer and it worked fine. It started.

      Only problem is when I'm trying to start SmartHomeServer from Qt Creator on my local computer (cross-compile). Does anyone can help me where might be problem. Maybe missing settings in Qt Creator?

      This is my SmartHomeServer.pro file:

      QT += core
      QT -= gui
      
      CONFIG += c++11
      
      TARGET = SmartHomeServer
      CONFIG += console
      CONFIG -= app_bundle
      
      TEMPLATE = app
      
      SOURCES += main.cpp
      
      # The following define makes your compiler emit warnings if you use
      # any feature of Qt which as 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 you use 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
      
      # Default rules for deployment.
      target.path = /home/pi/Documents/QtProjectsTests/SmartHomeServer
      INSTALLS += target
      
      # here are included my headers
      INCLUDEPATH += $$PWD/../SlaveDeviceModels
      
      # I tried do something like that
      #LIBS += -L/home/pi/Documents/QtProjectsTests/SmartHomeServe -lSlaveDeviceModels
      
      # that are default lines added by qt creator
      unix:!macx: LIBS += -L$$PWD/../build-SlaveDeviceModels-Raspberry_Pi_3_Kit-Debug/ -lSlaveDeviceModels
      INCLUDEPATH += $$PWD/../build-SlaveDeviceModels-Raspberry_Pi_3_Kit-Debug
      DEPENDPATH += $$PWD/../build-SlaveDeviceModels-Raspberry_Pi_3_Kit-Debug
      
      K Offline
      K Offline
      koahnig
      wrote on 17 Mar 2018, 17:46 last edited by
      #2

      @drewpol

      A static library is not a shared library. See here

      A static library is staically linked to an application making the application bigger.

      A shared library is a library which is shared between applications. Typically the sum of bytes required for all apps and libraries shall be less than the sum of bytes when you link the same applications with the same static library.

      When you have source which is used in more than one applciation, you typically create a library which is linked to the different applications. However, this library may be static or dynamic/shared. When you are creating a dynamic/shared library you will receive a static and the actual dynamic/shared library. The static part is containing the so-called stubs which are basically defining the entries to the routines in the shared/dynamic library.

      Vote the answer(s) that helped you to solve your issue(s)

      1 Reply Last reply
      3

      1/2

      17 Mar 2018, 16:52

      • Login

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