编译的 C++ 程序引发“无法打开共享对象文件"尽管文件存在,但在另一个系统上 [英] Compiled C++ program raises "cannot open shared object file" on another system though the file is present

查看:29
本文介绍了编译的 C++ 程序引发“无法打开共享对象文件"尽管文件存在,但在另一个系统上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写了一个小程序,它需要一些库,包括 libboost_filesystem、libboost_program_options 和 libcurl.

I wrote a tiny program that requires some libraries including libboost_filesystem, libboost_program_options and libcurl.

我在家里的机器上编译了它,然后把二进制文件带到我工作的电脑上进行测试.但是当我尝试启动程序时,它会给出以下错误消息:

I compiled it on my home machine and took the binary to my computer at work to test it there. But there it gives the following error message when I try to start the program:

error while loading shared libraries:
libboost_filesystem.so.1.42.0: cannot
open shared object file

但是当我搜索这个文件时,我发现它存在于:/usr/lib/libboost_filesystem.so.1.42.0

But when I search for this file I see that it exists in: /usr/lib/libboost_filesystem.so.1.42.0

我在编译/链接我的程序时有什么问题吗?如果是,我必须做什么才能使其在其他机器上运行?

Did I something wrong during the compilation / linking of my program? If yes what do I have to do to make it work on other machines?

推荐答案

首先尝试发出ldconfig -p |在控制台中 grep libboost_filesystem.so 以确保该库在您的 ld 缓存中.

First, try to issue ldconfig -p | grep libboost_filesystem.so in a console to make sure the library is in your ld cache.

如果不是,您可能需要将名称类似于 boost.conf 的文件添加到您的 /etc/ld.so.conf.d 目录中.这个文件应该包含你的 boost 库的路径.然后运行 ​​sudo ldconfig 来更新系统的 ld 缓存.

If it is not, you may need to add a file with a name like boost.conf to your /etc/ld.so.conf.d directory. This file should contain a path to your boost libraries. Then run sudo ldconfig to update your system's ld cache.

希望这会有所帮助...

Hope this will help...

这篇关于编译的 C++ 程序引发“无法打开共享对象文件"尽管文件存在,但在另一个系统上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆