1

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?

Steve
  • 551
  • 2
  • 8
  • 18
  • 2
    `export LD_LIBRARY_PATH=$PWD:$LD_LIBRARY_PATH` – Alok Singhal Dec 22 '09 at 05:31
  • 1
    Duplicate of http://stackoverflow.com/questions/1785617/shared-library-path-as-executable-directory –  Dec 22 '09 at 05:50
  • I agree, Roger, that the answer to SO 1785617 provides the answer to this, but it is certainly not obvious that they are simple duplicates. – Jonathan Leffler Dec 22 '09 at 20:42
  • I didn't mention the duplicate to disparage the OP; I just found it, recognized that it is a duplicate, and knew it'd be useful. –  Dec 22 '09 at 21:02

3 Answers3

3

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
  • 11,850
  • 4
  • 34
  • 50
0

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
  • 56,922
  • 16
  • 83
  • 148
0

Try executing the following line before running your application:

export LD_LIBRARY_PATH=.
Kyle Lutz
  • 7,966
  • 2
  • 20
  • 23
  • 1
    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 Dec 22 '09 at 20:43