打开失败:没有这样的文件或目录
我已经构建了一个引用我的 .so 对象的独立可执行文件。 两者都在同一目录中。当我尝试运行可执行文件时,出现以下错误:
ld.so.1:myExec:致命:libMine.so: 打开失败:没有这样的文件或目录
我做错了什么?
I have built a standalone executable which references my .so object.
both are in the same directory. when I try to run executable it gives me the following error:
ld.so.1: myExec: fatal: libMine.so:
open failed: No such file or directory
what am I doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
Unix 系统不会自动在当前目录中查找 .so 文件。
您可以通过设置 LD_LIBRARY_PATH 来解决这个问题,但在正常安装过程中,它们应该安装在系统上的适当位置。
另请参阅为什么不应让用户使用
LD_LIBRARY_PATH
Unix systems don't look in the current directory for .so files automatically.
You can get around this for development by setting
LD_LIBRARY_PATH
, but during the normal installation they should be installed in the appropriate place on the system.See also why you shouldn't make your users use
LD_LIBRARY_PATH
是的,正如 Alok 所说,lib 加载路径没有包含 .so 的目录。甚至不假定当前工作目录;它必须在 LD_LIBRARY_PATH 中显式列出。
Yes, as Alok says, the lib load path doesn't have the directory in which the .so is contained. Not even the current working directory is assumed; it must be explicitly listed in
LD_LIBRARY_PATH
.在运行应用程序之前尝试执行以下行:
Try executing the following line before running your application: