PDA

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



Compeau
3rd June 2010, 16:32
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.

JD2000
3rd June 2010, 18:42
Have you tried modifying the run settings?
- choose Projects from the left hand side
- on the run settings tab select 'run in terminal'

Compeau
3rd June 2010, 20:35
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.

squidge
3rd June 2010, 21:04
What is the actual error message?

Compeau
3rd June 2010, 21:35
What is the actual error message?

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

squidge
3rd June 2010, 22:04
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.

ChrisW67
3rd June 2010, 22:59
What is your current directory when you run the program?
What does:
ldd your_program_exe 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()?

Compeau
4th June 2010, 14:52
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"