I am trying to compile and run a C++ program on a server where I don't have root access. I am having trouble linkingboost_iostreams
library.
I can successfully compile my program by pointing to the boost installation directory using the -L
flag as:
g++ -I path/to/boost/build/include -o out prog1.cpp prog2.cpp -L path/to/boost/build/lib -lboost_iostreams
However, if I run the program as ./out
I get the error error while loading shared libraries: libboost_iostreams.so.1.67.0: cannot open shared object file: No such file or directory
since the linker is not able to locate libboost_iostreams.so.1.67.0
(which DOES exist under path/to/boost/build/lib
)
Thanks to this answer, I was able to explicitly specify LD_LIBRARY_PATH
and run the program as
LD_LIBRARY_PATH="path/to/boost/build/lib" ./out
.
Since I am not root, I can't run ldconfig
either. I was wondering if there is a way to load dynamic libraries without having to prefix LD_LIBRARY_PATH
when you run the program and no root access.