Linux 构建 GCC 4.6 - libmpfr.so.4 - 无法打开共享对象文件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5905434/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-05 03:57:36  来源:igfitidea点击:

Building GCC 4.6 - libmpfr.so.4 - cannot open shared object file

linuxgccconfiguration

提问by user2023370

I'm trying to build GCC 4.6 under CentOS release 5.5 (Final). I've freshly built GMP-5.0.1, MPC-0.9, and MPFR-3.0.1, and have used the following configure command:

我正在尝试在 CentOS 5.5 版(最终版)下构建 GCC 4.6。我刚刚构建了 GMP-5.0.1、MPC-0.9 和 MPFR-3.0.1,并使用了以下配置命令:

../configure --prefix=/users/xxxx/apps/mygcc4.6 --disable-checking --enable-threads=posix --enable-languages=c,c++,fortran --with-mpfr=/users/xxxx/code/gcc/mpfr-3.0.1-install-cyprus --with-gmp=/users/xxxx/code/gcc/gmp-5.0.1-install-cyprus --with-mpc=/users/xxxx/code/gcc/mpc-0.9-install-cyprus

../configure --prefix=/users/xxxx/apps/mygcc4.6 --disable-checking --enable-threads=posix --enable-languages=c,c++,fortran --with-mpfr=/users/ xxxx/code/gcc/mpfr-3.0.1-install-cyprus --with-gmp=/users/xxxx/code/gcc/gmp-5.0.1-install-cyprus --with-mpc=/users/xxxx/代码/gcc/mpc-0.9-install-cyprus

After this, I run make and after about 5 minutes get the following error message:

在此之后,我运行 make 并在大约 5 分钟后收到以下错误消息:

checking for suffix of object files... configure: error: in /users/xxxx/code/gcc/gcc-4.6.0/obj/x86_64-unknown-linux-gnu/libgcc': configure: error: cannot compute suffix of object files: cannot compile Seeconfig.log' for more details.

检查目标文件的后缀...配置:错误:在/users/xxxx/code/gcc/gcc-4.6.0/obj/x86_64-unknown-linux-gnu/libgcc': configure: error: cannot compute suffix of object files: cannot compile Seeconfig.log 中了解更多详细信息。

The config.log indicates that a recently generated program (cc1) is involved:

config.log 表明涉及到最近生成的程序(cc1):

/users/xxxx/code/gcc/gcc-4.6.0/obj/./gcc/cc1

/users/xxxx/code/gcc/gcc-4.6.0/obj/./gcc/cc1

Indeed if I run this program with no arguments I get the same error message found in config.log:

事实上,如果我不带参数运行这个程序,我会在 config.log 中得到相同的错误消息:

error while loading shared libraries: libmpfr.so.4: cannot open shared object file: No such file or directory

加载共享库时出错:libmpfr.so.4:无法打开共享对象文件:没有这样的文件或目录

However, libmpfr.so.4 is in the lib subdirectory of that provided to configure using the --with-mpfr flag, as seen above. I have LD_LIBRARY_PATH and LIBRARY_PATH empty. Any idea how I can get past this error?

但是,libmpfr.so.4 位于使用 --with-mpfr 标志提供配置的 lib 子目录中,如上所示。我有 LD_LIBRARY_PATH 和 LIBRARY_PATH 空。知道如何克服这个错误吗?

采纳答案by Gunther Piez

Make sure your library is acutally in the directory given and not in some libsubdirectory. Use export LD_LIBRARY_PATH=/users/xxxx/code/gcc/mpfr-3.0.1-install-cyprusas you have already suggested ;-)

确保您的库确实在给定的目录中,而不是在某个lib子目录中。使用export LD_LIBRARY_PATH=/users/xxxx/code/gcc/mpfr-3.0.1-install-cyprus你已经建议;-)

回答by that_IT_guy

I know this thread is pretty outdated. But, I had to comment and say that after 5+ hours of banging my head against the wall on a very similar issue (checking for suffix of object files... configure: error: cannot compute suffix of object files: cannot compile) and having read the install manual, a multitude of forums, and trying various things on the system in question I found this brief but very useful post. The issue was precisely related to LD_LIBRARY_PATH. Long story short, when building from source if you hit this wall export the LD_LIBRARY_PATH variable to point into the source build directory for the libs. Worked for me anyway.

我知道这个线程已经过时了。但是,我不得不评论并说,在一个非常相似的问题(检查目标文件的后缀...配置:错误:无法计算目标文件的后缀:无法编译)上我的头撞到墙上 5 个多小时之后,并且阅读安装手册、大量论坛并在相关系统上尝试各种操作后,我发现这篇简短但非常有用的帖子。该问题与 LD_LIBRARY_PATH 完全相关。长话短说,当从源代码构建时,如果你碰到这堵墙,导出 LD_LIBRARY_PATH 变量以指向 libs 的源构建目录。无论如何都为我工作。

Good luck folks.

祝大家好运。

回答by Arnab Sanyal

I know that this thread is pretty outdated. I faced similar issues while installing mpfron WSL. The build was fine and mpfr installed correctly but when I wrote a small C file to see if I could access the header file and print the version fo the installation - I could compile the C file but When I tried to run the compiled object - it would give me an error. The C file was,

我知道这个线程已经过时了。我在 WSL 上安装mpfr时遇到了类似的问题。构建很好并且 mpfr 安装正确,但是当我编写一个小的 C 文件以查看是否可以访问头文件并打印安装版本时 - 我可以编译 C 文件但是当我尝试运行编译对象时 - 它会给我一个错误。C文件是,

#include <stdio.h>
#include <mpfr.h>

int main (void) {
    printf ("MPFR library: %-12s\nMPFR header: %s (based on %d.%d.%d)\n",
    mpfr_get_version (), MPFR_VERSION_STRING, MPFR_VERSION_MAJOR,
    MPFR_VERSION_MINOR, MPFR_VERSION_PATCHLEVEL);
    return 0;
}

I was compiling this with,

我正在编译这个,

gcc -o version mpfr_presence.c -lmpfr -lgmp

But when I tried to run this with ./version, I would get the following error,

但是当我尝试用 运行它时./version,我会收到以下错误,

./version: error while loading shared libraries: libmpfr.so.6: cannot open shared object file: No such file or directory

I solved this error using,

我解决了这个错误,

sudo apt-get update
sudo apt-get install libmpfr4

And then when it said that libmpfr4was already at its latest version, just to be sure,

然后当它说libmpfr4已经是最新版本时,可以肯定的是,

sudo apt-get install --reinstall libmpfr4

Now ./versiongives me,

现在./version给我,

MPFR library: 4.0.1
MPFR header: 4.0.1 (based on 4.0.1)