I just downloaded a
tar file that is supposed to include everything required to run a program that we can call
some_binary. I extracted it's contents, and I see the following:
- A binary (let's call it
libfolder with various dynamic libraries (.so files) such as
- and a shell script called
The script has the following contents:
#!/bin/bash `dirname "$0"`/lib/ld-linux-x86-64.so.2 `dirname "$0"`/some_binary "$@"
and running it as
./some_binary.sh some arguments seems to run
./some_binary correctly. Oddly enough, running the following script:
#!/bin/bash LD_LIBRARY_PATH=$CWD/LIB:$LD_LIBRARY_PATH ./some_binary "$@"
./my_script.sh some arguments does not work. It results in relocation errors (undefined symbols), presumably from incorrectly loading the libraries under
Moreover, running the following two statements from the command line results in
> LD_LIBRARY_PATH=$CWD/LIB:$LD_LIBRARY_PATH > ./some_binary some arguments
With this, my questions are:
- What does the first script do?
- Why do I get different results across these three attempts? and why can't I just add
LD_LIBRARY_PATHand then run