Results 1 to 7 of 7

Thread: Lib not found in execution.

  1. #1
    Join Date
    Sep 2009
    Posts
    15
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Lib not found in execution.

    Hi, im trying to run a program.
    I have a .so library that i link against. I added this in the .pro:

    Qt Code:
    1. linux*:LIBS += -L..lib/linux -loscpack
    To copy to clipboard, switch view to plain text mode 

    I had to rename it from liboscpack.so.1.0.2 to liboscpack.so to compile.

    It gave me this error in execution:

    Qt Code:
    1. error while loading shared libraries: liboscpack.so: cannot open shared object file: No such file or directory
    To copy to clipboard, switch view to plain text mode 

    If i copy the library to the executable folder, i can run it from inside qtCreator, but it still gives me the error from nautilus.

    What am i doing wrong? Thanks in advance

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Lib not found in execution.

    Your libs location needs to be known to the running application.
    Add it to your LD_LIBRARY_PATH, and should solve the problem.
    Or, you can put your lib in an already known location to LD_LIBRARY_PATH.
    You don't need to rename your lib, you can make a symbolic link to it.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. #3
    Join Date
    Sep 2009
    Posts
    15
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Lib not found in execution.

    Thanks, but i would like the program to run in any machine. Is there any way to set the executable to look for that library in a folder, at runtime?

  4. #4
    Join Date
    Sep 2009
    Posts
    15
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Lib not found in execution.

    Ive read about the -R option in compilation to avoid changing LD_LIBRARY_PATH.
    This tells the executable where to find the linked library.

    How can i set this in Qt?

    PD: im trying to make it work using QMAKE_LFLAGS

    Qt Code:
    1. QMAKE_LFLAGS += -rpath ./
    To copy to clipboard, switch view to plain text mode 

    But it doesnt seem to work
    Last edited by Netich; 27th October 2009 at 12:34.

  5. #5
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Lib not found in execution.

    Is there any way to set the executable to look for that library in a folder, at runtime?
    You have the choice either to supply the lib with your application, then you know where it is, or, if its a lib that should be in a known location on each system, then you can code the search for it for each OS your application supports.
    If you have static examples of the lib, you can static link to it, then you don't need to look for anything - this ofcourse will make your exe much larger, depending on how large are the libs you are linking to.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  6. #6
    Join Date
    Sep 2009
    Posts
    15
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Lib not found in execution.

    Quote Originally Posted by high_flyer View Post
    You have the choice either to supply the lib with your application, then you know where it is, or, if its a lib that should be in a known location on each system, then you can code the search for it for each OS your application supports.
    If you have static examples of the lib, you can static link to it, then you don't need to look for anything - this ofcourse will make your exe much larger, depending on how large are the libs you are linking to.
    The idea is to give the .so with the executable, but i dont want to link statically, becouse we want to share the project, so the user would have to compile Qt as static, to use our project and run it.

    Ive made an script to run the program, modifying LD_LIBRARY_PATH:
    Qt Code:
    1. LD_LIBRARY_PATH=$LD_LIBRARY_PATH:../../libs/oscpack/lib/linux/
    2. export LD_LIBRARY_PATH
    3. ./program
    To copy to clipboard, switch view to plain text mode 

    but its not the ideal solution, so any help will be appreciated

  7. #7
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Lib not found in execution.

    The ideal solution would be to ask the user to install Qt before installing your software, or package the software in such a way that either you install Qt during installation of your software, or you get a package manager to install it for you.

    That way if Qt is already installed because another package on the machine needs it, then you don't have to bundle it with your app. It would be daft to have several installations of Qt because several applications require it.

    For example, if you look here: http://rpm.pbone.net/index.php3/stat....i586.rpm.html

    When you attempt to install that software, the installer will notice the "Requires" section and automatically download and install them if they are not already installed (and also any packages that those packages may depend on, and so on)

Similar Threads

  1. Replies: 8
    Last Post: 27th October 2009, 09:07
  2. Visual Studio 2005 Express
    By Muzz in forum Installation and Deployment
    Replies: 22
    Last Post: 6th November 2008, 06:21
  3. Replies: 12
    Last Post: 9th April 2008, 13:49
  4. Program crashes with assert error in xcb_lock.c
    By Valheru in forum Qt Programming
    Replies: 3
    Last Post: 18th November 2007, 19:56
  5. KDE 3.5.0 crash while opening project
    By MarkoSan in forum KDE Forum
    Replies: 2
    Last Post: 19th October 2007, 16:21

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.