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. How to include shared library?
Forum Updated to NodeBB v4.3 + New Features

How to include shared library?

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 3 Posters 1.1k 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.
  • G Offline
    G Offline
    Guerrian
    wrote on 6 Feb 2020, 13:19 last edited by Guerrian 2 Jun 2020, 13:19
    #1

    I have a console application that runs in Qt Creator. However when I try to run it in the terminal I get an error concerning a library:

    error while loading shared libraries: libCbcSolver.so.0: cannot open shared object file: No such file or directory
    

    The "pro" file has the lines to link to the library:

    LIBS += -L/home/daniel/Documents/COINOR/Cbc-2.10/build/lib -lCbc -lCbcSolver
    INCLUDEPATH += /home/daniel/Documents/COINOR/Cbc-2.10/build/include/coin
    

    Is there a way to include the shared library into the executable? So there is no need for:

    LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/daniel/Documents/COINOR/Cbc-2.10/build/lib
    export LD_LIBRARY_PATH
    

    Linux Mint 18.3
    Qt 5.14.1
    Qt Creator 4.11.1

    J 1 Reply Last reply 6 Feb 2020, 13:25
    0
    • G Guerrian
      6 Feb 2020, 13:19

      I have a console application that runs in Qt Creator. However when I try to run it in the terminal I get an error concerning a library:

      error while loading shared libraries: libCbcSolver.so.0: cannot open shared object file: No such file or directory
      

      The "pro" file has the lines to link to the library:

      LIBS += -L/home/daniel/Documents/COINOR/Cbc-2.10/build/lib -lCbc -lCbcSolver
      INCLUDEPATH += /home/daniel/Documents/COINOR/Cbc-2.10/build/include/coin
      

      Is there a way to include the shared library into the executable? So there is no need for:

      LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/daniel/Documents/COINOR/Cbc-2.10/build/lib
      export LD_LIBRARY_PATH
      
      J Offline
      J Offline
      jsulm
      Lifetime Qt Champion
      wrote on 6 Feb 2020, 13:25 last edited by
      #2

      @Guerrian said in How to include shared library?:

      Is there a way to include the shared library into the executable?

      Either build the lib as static libs or add the library code to your project.

      But actually you should simply deploy your app with all needed libs properly: https://doc.qt.io/qt-5/linux-deployment.html

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      4
      • M Offline
        M Offline
        mrdebug
        wrote on 6 Feb 2020, 14:36 last edited by
        #3

        On Linux try to use
        unix:!mac {
        LIBS += -Wl,-rpath=\$$ORIGIN/libs
        }
        makes portable your application

        Need programmers to hire?
        www.labcsp.com
        www.denisgottardello.it
        GMT+1
        Skype: mrdebug

        1 Reply Last reply
        0

        1/3

        6 Feb 2020, 13:19

        • Login

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