gpt4 book ai didi

linux - Debian Wheezy 7.5-用户 session 中未加载变量LD_LIBRARY_PATH

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:53:51 27 4
gpt4 key购买 nike

系统:Debian 7.5喘息
大家好!啊!
简短版本:ld_library_path环境变量未正确加载,但在/etc/profile.d中设置它的脚本似乎工作正常。
长版本:这些天来,我一直在执行qt5和几个库的安装。我已将这些安装到/opt文件夹中。要设置安装后所需的环境变量,请执行以下操作:

gedit setXXXVariables.sh
#!/bin/sh
export VARIABLE=value
export VARIABLE=$VARIABLE:more_values
sudo install -m755 setXXXVariables.sh /etc/profile.d

所以,我在profile.d中安装了几个脚本:
$ ls -l /etc/profile.d
total 36
-rw-r--r-- 1 root root 660 jun 17 2012 bash_completion.sh
-rwxr-xr-x 1 root root 184 jun 7 14:57 setAndroidNDKVariables.sh
-rwxr-xr-x 1 root root 203 jun 7 14:52 setAndroidSDKVariables.sh
-rwxr-xr-x 1 root root 188 jun 15 11:52 setAntVariables.sh
-rwxr-xr-x 1 root root 2444 jun 15 12:05 setIntelIPPVariables.sh
-rwxr-xr-x 1 root root 508 jun 15 13:15 setOpenCVVariables.sh
-rwxr-xr-x 1 root root 146 jun 7 15:02 setOracleJDKVariables.sh
-rwxr-xr-x 1 root root 241 jun 12 02:04 setQt5Variables.sh
-rwxr-xr-x 1 root root 235 jun 13 17:52 setVTKVariables.sh

每个文件的内容(不包括bash_completion.sh,它随系统提供,并且保持不变)如下:
setandroidndkvariables.sh:
#!/bin/sh
export ANDROID_NDK=/opt/AndroidNDK/android-ndk-r9d
export PATH=$PATH:$ANDROID_NDK

setandroidsdkvariables.sh:
#!/bin/sh
export ANDROID_SDK=/opt/AndroidSDK
export PATH=$PATH:$ANDROID_SDK/tools:$ANDROID_SDK/platform-tools

setantvariables.sh:设置变量:
#!/bin/sh
export ANT_HOME=/opt/ApacheAnt/apache-ant-1.9.4
export PATH=${PATH}:${ANT_HOME}/bin

setintelippvariables.sh:设置变量:
#!/bin/sh 

#RLP 08-06-14: Fichero shell para establecer variables globales de librería Intel IPP (Integrated Performance Primitives) para poder compilar OpenCV con IPP
#/opt/intel/bin/compilervars.sh intel64

#Por alguna razón la línea anterior no fuciona, así que procedemos a establecer las variables manualmente, tras analizar y comparar las generadas por dicho script
MI_VALOR=/opt/intel/composer_xe_2013_sp1.3.174/ipp/include
if [ -z "${CPATH}" ]
then
export CPATH=$MI_VALOR
else
export CPATH=$CPATH:$MI_VALOR
fi

export INTEL_LICENSE_FILE=/opt/intel/composer_xe_2013_sp1.3.174/licenses:/opt/intel/licenses:$HOME/intel/licenses
export IPPROOT=/opt/intel/composer_xe_2013_sp1.3.174/ipp

MI_VALOR=/opt/intel/composer_xe_2013_sp1.3.174/compiler/lib/intel64:/opt/intel/composer_xe_2013_sp1.3.174/mpirt/lib/intel64:/opt/intel/composer_xe_2013_sp1.3.174/compiler/lib/intel64:/opt/intel/composer_xe_2013_sp1.3.174/ipp/lib/intel64
if [ -z "${LD_LIBRARY_PATH}" ]
then
export LD_LIBRARY_PATH=$MI_VALOR
else
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$MI_VALOR
fi

MI_VALOR=/opt/intel/composer_xe_2013_sp1.3.174/compiler/lib/intel64:/opt/intel/composer_xe_2013_sp1.3.174/ipp/lib/intel64
if [ -z "${LIBRARY_PATH}" ]
then
export LIBRARY_PATH=$MI_VALOR
else
export LIBRARY_PATH=$LIBRARY_PATH:$MI_VALOR
fi

#export MANPATH=/opt/intel/composer_xe_2013_sp1.3.174/man/en_US:/usr/local/man:/usr/local/share/man:/usr/share/man:
MI_VALOR=/opt/intel/composer_xe_2013_sp1.3.174/man/en_US
if [ -z "${MANPATH}" ]
then
export MANPATH=$MI_VALOR
else
export MANPATH=$MANPATH:$MI_VALOR
fi

MI_VALOR=/opt/intel/composer_xe_2013_sp1.3.174/compiler/lib/mic:/opt/intel/composer_xe_2013_sp1.3.174/mpirt/lib/mic
if [ -z "${MIC_LD_LIBRARY_PATH}" ]
then
export MIC_LD_LIBRARY_PATH=$MI_VALOR
else
export MIC_LD_LIBRARY_PATH=$MIC_LD_LIBRARY_PATH:$MI_VALOR
fi

#Look out for NLSPATH var
MI_VALOR="/opt/intel/composer_xe_2013_sp1.3.174/compiler/lib/intel64/locale/%l_%t/%N:/opt/intel/composer_xe_2013_sp1.3.174/ipp/lib/intel64/locale/%l_%t/%N"
if [ -z "${NLSPATH}" ]
then
export NLSPATH=$MI_VALOR
else
export NLSPATH=$NLSPATH:$MI_VALOR
fi

export PATH=$PATH:/opt/intel/composer_xe_2013_sp1.3.174/bin/intel64:/opt/intel/composer_xe_2013_sp1.3.174/mpirt/bin/intel64

setopencvvariables.sh:设置打开变量:
#!/bin/sh

MI_VALOR=/opt/OpenCV/OpenCV-2.4.9/lib/pkgconfig
if [ -z "$PKG_CONFIG_PATH" ]
then
export PKG_CONFIG_PATH=$MI_VALOR
else
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$MI_VALOR
fi

MI_VALOR=/opt/OpenCV/OpenCV-2.4.9/lib
if [ -z "$LD_LIBRARY_PATH" ]
then
export LD_LIBRARY_PATH=$MI_VALOR
else
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$MI_VALOR
fi

setoraclejdkvariables.sh:
#!/bin/sh
export JAVA_HOME=/opt/OracleJDK/jdk1.8.0_05

setqt5变量.sh:
#!/bin/sh
export QT5=/opt/Qt/5.3/gcc_64/bin
export PATH=$PATH:$QT5
export QT_QMAKE_EXECUTABLE=/opt/Qt/5.3/gcc_64/bin/qmake

setvtkvariables.sh:设置变量:
#!/bin/sh 
export VTK_DIR=/opt/VTK/VTK-6.1

但是有些变量,特别是ld_library_path没有正确加载。
为了测试这个,我在$HOME文件夹中创建了这个脚本:
echo "CPATH:"; echo $CPATH
echo "INTEL_LICENSE_FILE:"; echo $INTEL_LICENSE_FILE
echo "IPPROOT:"; echo $IPPROOT
echo "LD_LIBRARY_PATH:"; echo $LD_LIBRARY_PATH
echo "LIBRARY_PATH:"; echo $LIBRARY_PATH
echo "MANPATH:"; echo $MANPATH
echo "IC_LD_LIBRARY_PATH:"; echo $MIC_LD_LIBRARY_PATH
echo "NLSPATH:"; echo $NLSPATH
echo "PATH:"; echo $PATH
echo "PKG_CONFIG_PATH:"; echo $PKG_CONFIG_PATH
echo "JAVA_HOME:"; echo $JAVA_HOME
echo "QT5:"; echo $QT5
echo "QT_QMAKE_EXECUTABLE:"; echo $QT_QMAKE_EXECUTABLE
echo "VTK_DIR:"; echo $VTK_DIR

现在,我登录default gui(gnome 3),打开一个终端窗口,并执行此脚本以查看值:
./printMyEnvs.sh

注册电话:
/opt/intel/composer_xe_2013_sp1.3.174/ipp/包含
英特尔许可证文件:
/opt/intel/composer_xe_2013_sp1.3.174/licenses:/opt/intel/licenses:/home/rlp/intel/licenses/许可证
Ipproot公司:
/opt/intel/composer_xe_2013_sp1.3.174/ipp
图书馆路径:
库路径:
/opt/intel/composer_xe_2013_sp1.3.174/compiler/lib/intel64:/opt/intel/composer_xe_2013_sp1.3.174/ipp/lib/intel64
人行路径:
/opt/intel/composer_xe_2013_sp1.3.174/man/en_美国
图书馆路径:
/opt/intel/composer_xe_2013_sp1.3.174/compiler/lib/mic:/opt/intel/composer_xe_2013_sp1.3.174/mpirt/lib/mic
NLSPATH公司:
路径:
//local/bin:/usr/bin:/bin:/bin:/usr/local/games:/usr/games:/usr/games:/opt/android ndk/android-ndk-ndk-ndk-ndk-r9d:/opt/androididdk/tools:/opt/androididdk/platform/tools/opt/apache ant/apacheant-ant-1.9.4/bin:/opt/opt/intel/apacheant/apacheant-ant-1.9.4.4/bin:/opt/opt/opt/intel/apacheant/apacheant/apacheant-ant-ant-ant-ant-ant-ant-1.9.9 U 64/箱
包配置路径:
/opt/opencv/opencv-2.4.9/lib/pkgconfig选项
爪哇之家:
/opt/oraclejdk/jdk1.8.0_05选项
第5季度:
/选项/qt/5.3/gcc_64/bin
qt_qmake_可执行文件:
/选项/qt/5.3/gcc_64/bin/qmake
vtk_目录:
/opt/vtk/vtk-6.1版本
注意nlspath和ld_libary_path没有正确设置。
现在,如果我进入纯登录shell(crtl+f1打开纯登录shell模式):
./printMyEnvs.sh

注册电话:
/opt/intel/composer_xe_2013_sp1.3.174/ipp/包含
英特尔许可证文件:
/opt/intel/composer_xe_2013_sp1.3.174/licenses:/opt/intel/licenses:/home/rlp/intel/licenses/许可证
Ipproot公司:
/opt/intel/composer_xe_2013_sp1.3.174/ipp
图书馆路径:
/opt/intel/composer_xeu 2013_xe sp1.3.174/compiler/lib/intel64:/opt/intel/composer_xeu 2013_xe sp1.3.174/mpirt/lib/intel64:/opt/intel/composer_xeu 2013_xe sp1.3.174/compiler/lib/intel64:/opt/intel/composer_xe sp1.3.174/ipp/lib/intel64:/opt/opencv/opencv-2.4.9/lib
库路径:
/opt/intel/composer_xe_2013_sp1.3.174/compiler/lib/intel64:/opt/intel/composer_xe_2013_sp1.3.174/ipp/lib/intel64
人行路径:
/opt/intel/composer_xe_2013_sp1.3.174/man/en_美国
图书馆路径:
/opt/intel/composer_xe_2013_sp1.3.174/compiler/lib/mic:/opt/intel/composer_xe_2013_sp1.3.174/mpirt/lib/mic
NLSPATH公司:
/opt/intel/composer_xe_2013_sp1.3.174/compiler/lib/intel64/locale/%l_%t/%n:/opt/intel/composer_xe_2013_sp1.3.174/ipp/lib/intel64/locale/%l_%t/%n
路径:
//local/bin:/usr/bin:/bin:/bin:/usr/local/games:/usr/games:/usr/games:/opt/android ndk/android-ndk-ndk-ndk-ndk-r9d:/opt/androididdk/tools:/opt/androididdk/platform/tools/opt/apache ant/apacheant-ant-1.9.4/bin:/opt/opt/intel/apacheant/apacheant-ant-1.9.4.4/bin:/opt/opt/opt/intel/apacheant/apacheant/apacheant-ant-ant-ant-ant-ant-ant-1.9.9 U 64/箱
包配置路径:
/opt/opencv/opencv-2.4.9/lib/pkgconfig选项
爪哇之家:
/opt/oraclejdk/jdk1.8.0_05选项
第5季度:
/选项/qt/5.3/gcc_64/bin
qt_qmake_可执行文件:
/选项/qt/5.3/gcc_64/bin/qmake
vtk_目录:
/opt/vtk/vtk-6.1版本
如您所见,现在所有变量都已正确设置!!为什么我在gnome中打开终端窗口时没有设置ld_library_path和nlspath?
有人可能会说,在debian/etc/profile.d中,不是导出变量的好地方,但其他变量都可以……
编辑:
如果我将重新定义ld library路径的行添加到/etc/profile,则结果与上面描述的相同(shell登录中的变量ok,图形终端中为空)。这是有意义的,因为/etc/profile只在创建登录shell时执行。但其他变量在终端窗口中正确加载…
图书馆路径是否由系统以某种特殊方式管理?
编辑2:
如果打开终端窗口并强制其输入登录名:
sudo login

完成后,我可以看到所有的变量,包括ld_library_path。所以,这是一个关于“登录shell”和“非登录shell”的问题…但这毫无意义,因为有些变量已经加载,而另一些没有加载。感到困惑…

最佳答案

找到了一个可以接受的解决方法。
我已经挣扎了整整两天了…直到今天下午我发了这篇文章,今天晚上我找到了一个解释和解决办法。我看到的最有用的链接是https://bugs.launchpad.net/ubuntu/+source/xorg/+bug/366728/comments/17
基本上,x11中的ssh init进程重置ld_library_path和nlspath,因此从窗口管理器启动的程序和终端(它们不是登录shell)会发现这些变量为空。解决方案是在X11重置之前导出它们:
变量ld_library_path:

sudo gedit /etc/X11/Xsession.d/89preserve_ld_library_path

#RLP 15-06-2014: workaround to get LD_LIBRARY_PATH exported (mainly for OpenCV and Intel IPP libraries, and future others)
STARTUP="/usr/bin/env LD_LIBRARY_PATH=${LD_LIBRARY_PATH} ${STARTUP}"

变量nlspath:
sudo gedit /etc/X11/Xsession.d/89preserve_nlspath

#RLP 15-06-2014: workaround to get NLSPATH exported (mainly for Intel IPP library)
STARTUP="/usr/bin/env NLSPATH=${NLSPATH} ${STARTUP}"

我发现有一点非常值得注意,那就是它是2009年以来发现的一个问题/bug,现在没有标准的解决方案。

关于linux - Debian Wheezy 7.5-用户 session 中未加载变量LD_LIBRARY_PATH,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24230948/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com