Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. Deploy shared library to raspberry
Forum Updated to NodeBB v4.3 + New Features

Deploy shared library to raspberry

Scheduled Pinned Locked Moved Solved Installation and Deployment
7 Posts 3 Posters 1.4k Views 1 Watching
  • 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
    davidino
    wrote on last edited by davidino
    #1

    Goodmorning,
    I've made a Subdir project with a shared library and a qt quick projects in it.
    The .pro file of the shared library is:

    #-------------------------------------------------
    #
    # Project created by QtCreator 2016-04-16T15:08:40
    #
    #-------------------------------------------------
    
    QT       += sql
    QT       -= gui
    
    TARGET = gallery-core
    TEMPLATE = lib
    CONFIG += lib c++11
    
    DEFINES += GALLERYCORE_LIBRARY
    
    SOURCES += \
        AlbumModel.cpp \
        DatabaseManager.cpp \
        Album.cpp \
        Picture.cpp \
        PictureModel.cpp \
        AlbumDao.cpp \
        PictureDao.cpp
    
    HEADERS += \
        gallery-core_global.h \
        AlbumModel.h \
        DatabaseManager.h \
        Album.h \
        Picture.h \
        PictureModel.h \
        AlbumDao.h \
        PictureDao.h
    
    
    

    The qt quick .pro file is:

    TEMPLATE = app
    
    QT += qml quick sql svg
    
    CONFIG += c++11
    
    SOURCES += main.cpp \
        PictureImageProvider.cpp
    
    RESOURCES += gallery.qrc
    
    LIBS += -L$$OUT_PWD/../gallery-core/ -lgallery-core
    INCLUDEPATH += $$PWD/../gallery-core
    DEPENDPATH += $$PWD/../gallery-core
    
    HEADERS += \
        PictureImageProvider.h
    
    contains(ANDROID_TARGET_ARCH,x86) {
        ANDROID_EXTRA_LIBS = \
            $$[QT_INSTALL_LIBS]/libQt5Sql.so
    }
    
    # Default rules for deployment.
    target.path = /home/davide
    INSTALLS += target
    
    

    The problem that I'm facing is that qt deploys correctly the application but it launches the following error:
    /home/davide/gallery-mobile: error while loading shared libraries: libgallery-core.so.1: cannot open shared object file: No such file or directory

    Basically the app is deployed on raspberry but the library .so doesn't.
    I tried using static shared library but it doesn't change a thing.
    Can you suggest me modifications for transfer the library file as well?

    Thank you.

    aha_1980A 1 Reply Last reply
    0
    • D davidino

      Goodmorning,
      I've made a Subdir project with a shared library and a qt quick projects in it.
      The .pro file of the shared library is:

      #-------------------------------------------------
      #
      # Project created by QtCreator 2016-04-16T15:08:40
      #
      #-------------------------------------------------
      
      QT       += sql
      QT       -= gui
      
      TARGET = gallery-core
      TEMPLATE = lib
      CONFIG += lib c++11
      
      DEFINES += GALLERYCORE_LIBRARY
      
      SOURCES += \
          AlbumModel.cpp \
          DatabaseManager.cpp \
          Album.cpp \
          Picture.cpp \
          PictureModel.cpp \
          AlbumDao.cpp \
          PictureDao.cpp
      
      HEADERS += \
          gallery-core_global.h \
          AlbumModel.h \
          DatabaseManager.h \
          Album.h \
          Picture.h \
          PictureModel.h \
          AlbumDao.h \
          PictureDao.h
      
      
      

      The qt quick .pro file is:

      TEMPLATE = app
      
      QT += qml quick sql svg
      
      CONFIG += c++11
      
      SOURCES += main.cpp \
          PictureImageProvider.cpp
      
      RESOURCES += gallery.qrc
      
      LIBS += -L$$OUT_PWD/../gallery-core/ -lgallery-core
      INCLUDEPATH += $$PWD/../gallery-core
      DEPENDPATH += $$PWD/../gallery-core
      
      HEADERS += \
          PictureImageProvider.h
      
      contains(ANDROID_TARGET_ARCH,x86) {
          ANDROID_EXTRA_LIBS = \
              $$[QT_INSTALL_LIBS]/libQt5Sql.so
      }
      
      # Default rules for deployment.
      target.path = /home/davide
      INSTALLS += target
      
      

      The problem that I'm facing is that qt deploys correctly the application but it launches the following error:
      /home/davide/gallery-mobile: error while loading shared libraries: libgallery-core.so.1: cannot open shared object file: No such file or directory

      Basically the app is deployed on raspberry but the library .so doesn't.
      I tried using static shared library but it doesn't change a thing.
      Can you suggest me modifications for transfer the library file as well?

      Thank you.

      aha_1980A Offline
      aha_1980A Offline
      aha_1980
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi @davidino,

      You have the following lines in your program project file:

      target.path = /home/davide
      INSTALLS += target

      But they seem to be missing in the librarys project file and therefore Creator does not deploy the library.

      Regards

      Qt has to stay free or it will die.

      1 Reply Last reply
      1
      • D Offline
        D Offline
        davidino
        wrote on last edited by davidino
        #3

        Hello aha_1980, thank you for your answer.
        I tried to add the lines suggested but I get the same error.
        I tried to add only in the .pro of the library and/or in the o.pro file of the Subdir project but unsuccessfully.
        I think there is another way for adding shared library to target

        aha_1980A 1 Reply Last reply
        0
        • D davidino

          Hello aha_1980, thank you for your answer.
          I tried to add the lines suggested but I get the same error.
          I tried to add only in the .pro of the library and/or in the o.pro file of the Subdir project but unsuccessfully.
          I think there is another way for adding shared library to target

          aha_1980A Offline
          aha_1980A Offline
          aha_1980
          Lifetime Qt Champion
          wrote on last edited by aha_1980
          #4

          @davidino said in Deploy shared library to raspberry:

          I think there is another way for adding shared library to target

          No, it isn't. You have to add these lines in all *.pro files defining a target (be it library or application). Please check Creators compile output when deploying to the target.

          You have of course to make sure, the app finds its library on the target, i.e. it is in a directory the dynamic linker will pick it up.

          Qt has to stay free or it will die.

          1 Reply Last reply
          3
          • D Offline
            D Offline
            davidino
            wrote on last edited by
            #5

            Hello aha_1980,
            thank you very much, I was wrong. It was sufficient to add :

            Default rules for deployment.

            target.path = /usr/lib
            INSTALLS += target
            So that the app could find the library deployed in /usr/lib.
            One last question: Since /usr/lib is the same folder as qt standard library, is there a way to let the app search the library in its very folder.
            Thank you again.

            A 1 Reply Last reply
            0
            • D davidino

              Hello aha_1980,
              thank you very much, I was wrong. It was sufficient to add :

              Default rules for deployment.

              target.path = /usr/lib
              INSTALLS += target
              So that the app could find the library deployed in /usr/lib.
              One last question: Since /usr/lib is the same folder as qt standard library, is there a way to let the app search the library in its very folder.
              Thank you again.

              A Offline
              A Offline
              ambershark
              wrote on last edited by
              #6

              @davidino Yes, you can use LD_LIBRARY_PATH for this. I usually just make a startup script for my app that looks something like:

              #!/bin/sh
              
              export LD_LIBRARY_PATH=".:$LD_LIBRARY_PATH"
              exec ./myapp "$@"
              

              That should look for libs in . which is the same dir as your binary ./myapp.

              You can test this on the command line without a script with:

              $ LD_LIBRARY_PATH=. ./myapp
              

              My L-GPL'd C++ Logger github.com/ambershark-mike/sharklog

              1 Reply Last reply
              4
              • D Offline
                D Offline
                davidino
                wrote on last edited by
                #7

                Hello, thank you to all.
                Now it works as I wanted.
                Davidino

                1 Reply Last reply
                1

                • Login

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