Siler
Siler

Reputation: 9504

modifying the linkage path of an executable

The ldd utility shows which shared object files a binary executable depends on, and also shows the path of that binary executable on the file system.

Is it possible to modify this path, on an existing executable? For example, suppose I have a binary "foo.so", and I say:

    libssl.so.0.9.8 => /opt/lib64/libssl.so.0.9.8

If I deploy this .so file to a machine that doesn't have lbssl.so.0.9.8 at the specified path, I will of course get a linker error when using foo.so. So, is it possible to modify the linkage path on an existing executable?

I realize another solution would be to ensure that the existing linkage path points to a valid object file actually copying the object file to the path that ldd shows. But let's say I have a situation where that's not feasible to do. Is it possible to modify the linkage path on an existing executable?

Upvotes: 2

Views: 1629

Answers (1)

Milind Dumbare
Milind Dumbare

Reputation: 3244

The path you are referring to is not executable specific. Its system specific. So when you take a binary from one machine to the next, the next machine could have totally different setup of putting libraries. So the binary on machine A might be linking at libraries in /usr/lib but the next machine B could be configured to link to libraires in /home/test/lib. just for an example.

When you want a executable to link to some other library (in /home/test/lib) than the default one. you do it by setting LD_LIBRARY_PATH=/home/test/lib.

look at http://wiredrevolution.com/system-administration/how-to-correctly-use-ld_library_path

Upvotes: 1

Related Questions