libarb.so: 无法打开共享对象文件: 没有那个文件或目录

4

我使用以下方式在Ubuntu安装了arb:

./configure
make
sudo make install 

我尝试运行以下代码:

#include <arb.h>

int main()
{
    arb_t x;
    arb_init(x);
    arb_const_pi(x, 50 * 3.33);
    arb_printn(x, 50, 0); printf("\n");
    printf("Computed with arb-%s\n", arb_version);
    arb_clear(x);
}

使用 -larb 库时遇到了错误。但在终端中我得到了以下错误:
error while loading shared libraries: libarb.so:
cannot open shared object file: No such file or directory

我该如何解决这个问题?

我搜索了一下,在 /usr/local/lib 目录下找到了一个 libarb.so 库文件。


尝试添加libarb的路径:-L /usr/local/lib -larb 但是,您确定在/usr/local/lib中有libarb.so吗?还是像libarb.so.x.y.z? - Sergio
是的,它是libarb.so。 - Minimus Heximus
这与C++有什么关系? - too honest for this site
我做了一个C++项目,但它看起来像是C语言。 - Minimus Heximus
https://askubuntu.com/questions/673637/libarb-so-libflint-so-13-cannot-open-shared-object-file-no-such-file-or-dire - Adam
2个回答

3

请检查并验证以下步骤

  1. 检查库是否存在,使用以下命令

find / -name "libarb.so"

  1. 使用-L选项编译您的程序,例如:
 gcc program.c -L <path to library> -larb
在运行之前,如果需要,请导出库路径。以下是示例。
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:<path to library>
在大多数情况下(考虑到所有访问权限都已正确设置),上述步骤应解决链接问题。

3

使用 ldconfig 命令将库添加到链接器缓存中。

为此,请在 /etc/ld.so.conf 中添加存储库的目录,然后以 root 身份执行 ldconfig


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接