I am having two problems related to the same problem:
I have a shared object stored in `pwd` / lib, and while the executable that uses it compiles successfully (using the -l and -L switches), at runtime it gives me sadness. If I try to run LD_LIBRARY_PATH=/my/absolute/path/to/library/directory ./testit works fine. But if I export the LD_LIBRARY_PATH = / my / absolute / path / to / library / directory and do it ./test, it says that it cannot find the shared library. However, if I do LD_LIBRARY_PATH=$LD_LIBRARY_PATH ./testagain, it works great !! Any ideas on what I'm doing wrong?
LD_LIBRARY_PATH=/my/absolute/path/to/library/directory ./test
./test
LD_LIBRARY_PATH=$LD_LIBRARY_PATH ./test
The second problem is related to the export of the EN_LIBRARY_PATH variable. If I open the terminal and export LD_LIBRARY_PATH=/path/to/stufftype and then enter echo $LD_LIBRARY_PATH, the variable is correct. However, if I write a script containing the export command by simply running it, it does not update the variable, instead I need to run source install.shto actually save the variable. What is the best solution for this?
export LD_LIBRARY_PATH=/path/to/stuff
echo $LD_LIBRARY_PATH
source install.sh
Thank you for your time!
First answer the second question :
sourceexecutes a script inside the current shell, ./install.shopens and executes it in another shell. http://www.unix.com/unix-dummies-questions-answers/537-difference-between-source-exec-script.html
source
./install.sh
Now for your first question:
LD_LIBRARY_PATH=$LD_LIBRARY_PATH ./test LD_LIBRARY_PATH ( ./test). , , ./test. , export LD_LIBRARY_PATH=... ~/.bashrc
export LD_LIBRARY_PATH=...
~/.bashrc
, -L CFLAGS , LD_RUN_PATH . : export CFLAGS = -L/opt/tool/lib