PDA

View Full Version : Lib not found in execution.



Netich
26th October 2009, 15:18
Hi, im trying to run a program.
I have a .so library that i link against. I added this in the .pro:


linux*:LIBS += -L..lib/linux -loscpack

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

It gave me this error in execution:


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

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

high_flyer
26th October 2009, 15:40
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.

Netich
27th October 2009, 11:36
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?

Netich
27th October 2009, 11:45
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


QMAKE_LFLAGS += -rpath ./

But it doesnt seem to work :(

high_flyer
29th October 2009, 17:04
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.

Netich
30th October 2009, 13:59
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:

LD_LIBRARY_PATH=$LD_LIBRARY_PATH:../../libs/oscpack/lib/linux/
export LD_LIBRARY_PATH
./program

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

squidge
30th October 2009, 14:28
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/4/idpl/12595931/com/QtDesigner-4.5.2-1.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)