uni*_*n83 0 linux centos environment-variables dependencies libraries
我已经编辑了我/etc/bashrc的设置,LD_LIBRARY_PATH就像我之前问的问题一样。不过好像没有生效。即使echo $LD_LIBRARY_PATH确实显示了我的修改。并运行我的程序:LD_LIBRARY_PATH="/usr/local/lib" ./test.cgi显式确实有效。我需要重新启动系统吗?这是怎么回事?
你需要export变量。
export LD_LIBRARY_PATH="/usr/local/lib"
./test.cgi
Run Code Online (Sandbox Code Playgroud)
您的公式LD_LIBRARY_PATH="/usr/local/lib" ./test.cgi在当前壳中设置变量。如果您只是在运行,LD_LIBRARY_PATH=/usr/local/lib ; ./test.cgi您将在当前 shell 中设置它,而不是在子进程 ./test.cgi 中。
从bash手册页:
export:
The supplied names are marked for automatic export to the environment of subsequently executed commands.
Run Code Online (Sandbox Code Playgroud)