首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场

LD库路径
EN

Ask Ubuntu用户
提问于 2014-06-14 18:21:51
回答 1查看 2.4K关注 0票数 1

我不确定我的LD_LIBRARY_PATH是否有效。

我在Ubuntu上安装了Qt5.2.1,并尝试使用sudo ./App1从命令行执行应用程序。( App1需要sudo访问,因此我以这种方式执行)

具有*.so文件Qt5.2.1/Tools/QtCreator/lib/qtcreator的文件夹在bashrc文件中的LD_LIBRARY_PATH中提供,但我得到了以下错误

代码语言:javascript
运行
复制
./App1: error while loading shared libraries: libQt5Quick.so.5: cannot open shared object file: No such file or directory

当我将所有Qt文件从QtCreator复制到/usr/lib时,应用程序工作正常。

有人能帮助我理解这个概念吗?为什么它不能从LD_LIBRARY_PATH中获取库,而它却可以处理标准/usr/lib路径中的Qt文件?

此外,在不将.so文件复制到/usr/lib的情况下,应该做些什么来使其工作。

EN

回答 1

Ask Ubuntu用户

发布于 2014-06-14 18:56:05

默认情况下,您的用户的LD_LIBRARY_PATH不会被sudo环境继承。根据sudoers手册(man sudoers):

代码语言:javascript
运行
复制
 By default, the env_reset option is enabled.  This causes commands to be
 executed with a new, minimal environment.  On AIX (and Linux systems
 without PAM), the environment is initialized with the contents of the
 /etc/environment file.  The new environment contains the TERM, PATH,
 HOME, MAIL, SHELL, LOGNAME, USER, USERNAME and SUDO_* variables in addi‐
 tion to variables from the invoking process permitted by the env_check
 and env_keep options.  This is effectively a whitelist for environment
 variables.

请注意,由于本节后面提到的原因,env_keep不太可能为LD_LIBRARY_PATH工作:

代码语言:javascript
运行
复制
 Note that the dynamic linker on most operating systems will remove vari‐
 ables that can control dynamic linking from the environment of setuid
 executables, including sudo.  Depending on the operating system this may
 include _RLD*, DYLD_*, LD_*, LDR_*, LIBPATH, SHLIB_PATH, and others.
 These type of variables are removed from the environment before sudo even
 begins execution and, as such, it is not possible for sudo to preserve
 them.

您必须找到一种方法,使您的应用程序在没有sudo的情况下运行,或者将其所需的库安装到标准库位置之一。

票数 0
EN
页面原文内容由Ask Ubuntu提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://askubuntu.com/questions/483320

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档