Recently, while creating a release package, i was facing a problem which, after some tries, I finally figured out the solution for. So here it is.
The need was to setup an environment by running a script, after which application can be run seamlessly. One of the entries in the script looked like =>
export LD_LIBRARY_PATH= $(pwd)/../lib:$LD_LIBRARY_PATH
The step was needed as the the package did install libraries in a separate path than the default one.
However even after i executed the script as " ./load.sh" , running applications still gave me error:
":error while loading shared libraries:
I was able to set the path inside the script and running the application from within the script worked, but from the terminal (parent process) which executed the script (child process) i was not able to set the env. paths.
The reason for the failure was that the settings done by the child process are not visible in the parent process.
Solution-> Execute script as part of parent process instead of forking, as:
. ./load.sh OR source ./load.sh
Happy shell scripting :)
No comments:
Post a Comment