C++ 制作 gcc4.8.1 时无法打开 libmpc.so.3
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17425982/
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
Cannot open libmpc.so.3 while making gcc4.8.1
提问by bucherren
I want to install gcc4.8.1 on ubuntu 10.04.
我想在 ubuntu 10.04 上安装 gcc4.8.1。
Here are my installing steps:
下面是我的安装步骤:
Install libgmp, libmpfr and libmpc.
After switch to gcc4.8.1 source code dir, run "./configure --prefix=/usr/bin/gcc4.8.1 --with-gmp=/opt/pkg/gmp5.1.2 --with-mpfr=/opt/pkg/mpfr3.1.2 --with-mpc=/opt/pkg/mpc1.0.1"
make
export LD_LIBRARY_PATH=/opt/pkg/gmp5.1.2/lib:/opt/pkg/mpfr3.1.2/lib:/opt/pkg/mpc1.0.1/lib
sudo make install.
安装 libgmp、libmpfr 和 libmpc。
切换到gcc4.8.1源码目录后,运行“./configure --prefix=/usr/bin/gcc4.8.1 --with-gmp=/opt/pkg/gmp5.1.2 --with-mpfr=/opt/ pkg/mpfr3.1.2 --with-mpc=/opt/pkg/mpc1.0.1"
制作
导出 LD_LIBRARY_PATH=/opt/pkg/gmp5.1.2/lib:/opt/pkg/mpfr3.1.2/lib:/opt/pkg/mpc1.0.1/lib
须藤制作安装。
In the last step I get this error:
在最后一步中,我收到此错误:
/usr/local/sbin/gcc-4.8.1/host-i686-pc-linux-gnu/gcc/cc1: error while loading shared libraries: libmpc.so.3: cannot open shared object file: No such file or directory
make[5]: *** [install-exec-hook] Error 1
make[5]: Leaving directory `/usr/local/sbin/gcc-4.8.1/i686-pc-linux-gnu/libjava'
make[4]: *** [install-exec-am] Error 2
make[4]: Leaving directory `/usr/local/sbin/gcc-4.8.1/i686-pc-linux-gnu/libjava'
make[3]: *** [install-am] Error 2
make[3]: Leaving directory `/usr/local/sbin/gcc-4.8.1/i686-pc-linux-gnu/libjava'
make[2]: *** [install-recursive] Error 1
make[2]: Leaving directory `/usr/local/sbin/gcc-4.8.1/i686-pc-linux-gnu/libjava'
make[1]: *** [install-target-libjava] Error 2
make[1]: Leaving directory `/usr/local/sbin/gcc-4.8.1'
make: *** [install] Error 2
I have switched to the libmpc library path and tested libmpc.so.3 with ldd. It has been installed successfully. Why does it say it cannot open shared object libmpc.so.3? How can I fix it?
我已经切换到 libmpc 库路径并使用 ldd 测试了 libmpc.so.3。它已成功安装。为什么说它不能打开共享对象libmpc.so.3?我该如何解决?
采纳答案by KiaMorot
You have to check if the libmpc.so.3 is a successfully created symbolic link to libmpc.so.3.0.0. This error may arise because you have installed this library manually and the sym. link may be missing. You could try this:
您必须检查 libmpc.so.3 是否是成功创建的指向 libmpc.so.3.0.0 的符号链接。出现此错误可能是因为您手动安装了此库和 sym。链接可能丢失。你可以试试这个:
sudo ln -s /opt/pkg/mpc1.0.1/lib/libmpc.so.3.0.0 /opt/pkg/mpc1.0.1/lib/libmpc.so.3
Syntax of ln
is ln -s <real path to file> <symbolic link name>
. For more check out the man page of ln
.
ln
is 的语法ln -s <real path to file> <symbolic link name>
。有关更多信息,请查看ln
.
回答by bucherren
According to your suggest, I have installed gcc4.8.1 successfully. Here are my steps:
根据你的建议,我已经成功安装了gcc4.8.1。这是我的步骤:
Remove gmp, mpfr and mpc from /opt/pkg.
Install gmp, mpfr and mpc with the default configure. These packages will be installed in /usr/local/lib.
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH.
Enter the gcc source dir, run "./configure".
make.
Add symbol links:
sudo ln -s /usr/local/lib/libgmp.so.10 /usr/lib/libgmp.so.10
sudo ln -s /usr/local/lib/libmpfr.so.4 /usr/lib/libmpfr.so.4
sudo ln -s /usr/local/lib/libmpc.so.3 /usr/lib/libmpc.so.3
sudo make install.
从 /opt/pkg 中删除 gmp、mpfr 和 mpc。
使用默认配置安装 gmp、mpfr 和 mpc。这些软件包将安装在 /usr/local/lib 中。
导出 LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH。
进入 gcc 源目录,运行“./configure”。
制作。
添加符号链接:
须藤 ln -s /usr/local/lib/libgmp.so.10 /usr/lib/libgmp.so.10
须藤 ln -s /usr/local/lib/libmpfr.so.4 /usr/lib/libmpfr.so.4
须藤 ln -s /usr/local/lib/libmpc.so.3 /usr/lib/libmpc.so.3
须藤制作安装。
Than you KiaMorot. Thank you trojanfoe.
比你起亚莫罗特。谢谢木马。
回答by Martin Konecny
I don't believe any of the answers here address the issue. Your problem is the last two steps
我不相信这里的任何答案都解决了这个问题。你的问题是最后两步
export LD_LIBRARY_PATH=/opt/pkg/gmp5.1.2/lib:/opt/pkg/mpfr3.1.2/lib:/opt/pkg/mpc1.0.1/lib
sudo make install
exporting your LD_LIBRARY_PATH
is correct, but then you reset all environment variables when you change to root user with sudo
in the last step.
导出LD_LIBRARY_PATH
是正确的,但是当您sudo
在最后一步更改为 root 用户时,您会重置所有环境变量。
One way to get around this:
解决此问题的一种方法:
sudo -s # become root user
export LD_LIBRARY_PATH=/opt/pkg/gmp5.1.2/lib:/opt/pkg/mpfr3.1.2/lib:/opt/pkg/mpc1.0.1/lib
make install # don't use sudo here
回答by cidermole
If anybody stumbles upon this using their own manually-built version of libgmp, libmpfr and libmpc instead of the system-provided ones:
如果有人使用他们自己手动构建的 libgmp、libmpfr 和 libmpc 版本而不是系统提供的版本偶然发现了这一点:
export LD_LIBRARY_PATH=/opt/your-prefix-directory
is necessary for make
itself, i.e. even when gcc
./configure
was run with
make
本身是必要的,即即使在gcc
./configure
运行时
--with-gmp=/opt/your-prefix-directory --with-mpc=/opt/your-prefix-directory --with-mpfr=/opt/your-prefix-directory
you need to specify where the linker should go looking for libgmp and friends.
您需要指定链接器应该去哪里寻找 libgmp 和朋友。