views:

108

answers:

3

I have built a standalone executable which references my .so object. both are in the same directory. when I try to run executable it gives me the following error:

ld.so.1: myExec: fatal: libMine.so: open failed: No such file or directory

what am I doing wrong?

A: 

Yes, as Alok says, the lib load path doesn't have the directory in which the .so is contained. Not even the current working directory is assumed; it must be explicitly listed in LD_LIBRARY_PATH.

wallyk
A: 

Try executing the following line before running your application:

export LD_LIBRARY_PATH=.
Kyle Lutz
That clobbers any pre-existing value - you might be better off with: `export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:.` (which extends the path, and puts the current directory at the end which is, perhaps, a little more secure).
Jonathan Leffler
+3  A: 

Unix systems don't look in the current directory for .so files automatically.

You can get around this for development by setting LD_LIBRARY_PATH, but during the normal installation they should be installed in the appropriate place on the system.

See also why you shouldn't make your users use LD_LIBRARY_PATH

Chris Arguin