Results 1 to 8 of 8

Thread: Program runs in QtCreator, but can't find libs when running through terminal

  1. #1
    Join Date
    May 2010
    Posts
    10
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Program runs in QtCreator, but can't find libs when running through terminal

    I created a simple program for Linux in QtCreator that links to some libraries. Initially it wouldn't run through QtCreator because it couldn't find the libraries, so I put all the required libs in the project directory, where the executable is. By doing this, the program runs through QtCreator, but when I try to run the program in the terminal, it says that it cannot find the libraries.

    I don't get this. The libraries are in the same directory as the executable, and it works through QtCreator, so why can't the program find them when running through the terminal?

    Any help would be greatly appreciated.

  2. #2
    Join Date
    Oct 2009
    Posts
    151
    Thanks
    6
    Thanked 13 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Program runs in QtCreator, but can't find libs when running through terminal

    Have you tried modifying the run settings?
    - choose Projects from the left hand side
    - on the run settings tab select 'run in terminal'
    Got to keep the loonies on the path ...

  3. #3
    Join Date
    May 2010
    Posts
    10
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Program runs in QtCreator, but can't find libs when running through terminal

    Quote Originally Posted by JD2000 View Post
    Have you tried modifying the run settings?
    - choose Projects from the left hand side
    - on the run settings tab select 'run in terminal'
    Just tried this. It changed how the program runs through QtCreator, but it still won't run if I ./ it in the shell.

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

    Default Re: Program runs in QtCreator, but can't find libs when running through terminal

    What is the actual error message?

  5. #5
    Join Date
    May 2010
    Posts
    10
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Program runs in QtCreator, but can't find libs when running through terminal

    Quote Originally Posted by fatjuicymole View Post
    What is the actual error message?
    "error while loading shared libraries: libBinLPlugin.so.0: cannot open shared object file: No such file or directory"

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

    Default Re: Program runs in QtCreator, but can't find libs when running through terminal

    Since your running Linux, is there a reason you have not installed the libraries in the default library search path?

    If so, you can set LD_LIBRARY_PATH to run your program.

  7. #7
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,734
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Program runs in QtCreator, but can't find libs when running through terminal

    What is your current directory when you run the program?
    What does:
    Qt Code:
    1. ldd your_program_exe
    To copy to clipboard, switch view to plain text mode 
    indicate about the libraries it is loading and where they are coming from?
    Is the program linked to libBinLPlugin.so or libBinLPlugin.so.0 explicitly? libSomething.so is normally a sym link to a versioned libSomething.so.x.y.z
    Do you have everything that libBinLPlugin.so.0 relies on? Try the ldd command on libBinLPlugin.so.0.
    If libBinLPlugin.so.0 is a dynamically loaded application plugin is it in the expected subdirectory or have you added the plugin directory QCoreApplication::addLibraryPath()?

  8. The following user says thank you to ChrisW67 for this useful post:

    zoz (4th June 2010)

  9. #8
    Join Date
    May 2010
    Posts
    10
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Program runs in QtCreator, but can't find libs when running through terminal

    Quote Originally Posted by fatjuicymole View Post
    Since your running Linux, is there a reason you have not installed the libraries in the default library search path?

    If so, you can set LD_LIBRARY_PATH to run your program.
    That did it, thanks. I had no idea how to set this, but a quick google search found the solution that worked. Here's what I did:

    1.) use < .bashrc > file in home directory
    2.) add this line: "LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/whatever/lib ; export LD_LIBRARY_PATH"

Similar Threads

  1. Program runs on Windows 7, crashes on Windows XP
    By JovianGhost in forum General Programming
    Replies: 8
    Last Post: 7th June 2010, 00:55
  2. running external console program by gui program
    By alireza.mixedreality in forum Qt Programming
    Replies: 4
    Last Post: 24th April 2010, 18:05
  3. Replies: 2
    Last Post: 24th May 2009, 17:05
  4. Replies: 4
    Last Post: 25th April 2009, 14:11
  5. Replies: 1
    Last Post: 17th May 2006, 00:23

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.