bucherren
bucherren

Reputation: 299

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

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?

Upvotes: 3

Views: 27681

Answers (4)

cidermole
cidermole

Reputation: 6078

If anybody stumbles upon this using their own manually-built version of libgmp, libmpfr and libmpc instead of the system-provided ones:

export LD_LIBRARY_PATH=/opt/your-prefix-directory

is necessary for make itself, i.e. even when gcc ./configure was run with

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

Upvotes: 2

Martin Konecny
Martin Konecny

Reputation: 59681

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

Upvotes: 2

bucherren
bucherren

Reputation: 299

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.

Upvotes: 6

KiaMorot
KiaMorot

Reputation: 1746

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:

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.

Upvotes: 1

Related Questions