Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot open libmpc.so.3 while making gcc4.8.1

Tags:

c++

gcc

I want to install gcc4.8.1 on ubuntu 10.04.

Here are my installing steps:

  1. Install libgmp, libmpfr and libmpc.

  2. 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"

  3. make

  4. export LD_LIBRARY_PATH=/opt/pkg/gmp5.1.2/lib:/opt/pkg/mpfr3.1.2/lib:/opt/pkg/mpc1.0.1/lib

  5. sudo make install.

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?

like image 386
bucherren Avatar asked Jun 13 '26 15:06

bucherren


2 Answers

According to your suggest, I have installed gcc4.8.1 successfully. Here are my steps:

  1. Remove gmp, mpfr and mpc from /opt/pkg.

  2. Install gmp, mpfr and mpc with the default configure. These packages will be installed in /usr/local/lib.

  3. export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH.

  4. Enter the gcc source dir, run "./configure".

  5. make.

  6. 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

  7. sudo make install.

Than you KiaMorot. Thank you trojanfoe.

like image 191
bucherren Avatar answered Jun 15 '26 07:06

bucherren


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.

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
like image 44
14 revs, 12 users 16% Avatar answered Jun 15 '26 05:06

14 revs, 12 users 16%