Why do I have to set LD_LIBRARY_PATH before running a program, even though I already linked the library locations in the compile stage?
3
votes
1
answer
3724
views
I am compiling a model using
make
. The model has a Makefile
that connects the source code with dependent libraries via flags that look like -L/lib1 -L/lib2
. But when I try to run that model, it fails unless I also ensure the environmental variable
export LD_LIBRARY_PATH=/lib1:/lib2
and points to the exact same libraries. This seems redundant to me.
What could be going on under the hood here? Why do I effectively have to specify the location of the libraries before compilation and before execution?
This might be a silly question; I'm not very experienced compiling to machine code, usually just use scripting languages.
Asked by Luke Davis
(344 rep)
Feb 18, 2018, 07:40 PM
Last activity: Jun 10, 2021, 06:14 PM
Last activity: Jun 10, 2021, 06:14 PM