I'm attempting to compile GCC 4.5.2 as part of the Linux from Scratch book (http://www.linuxfromscratch.org/lfs/view/stable/chapter05/gcc-pass1.html). My configure is as follows:

./configure \
    --target=$LFS_TGT --prefix=/tools \
    --disable-nls --disable-shared --disable-multilib \
    --disable-decimal-float --disable-threads \
    --disable-libmudflap --disable-libssp \
    --disable-libgomp --enable-languages=c \
    --with-gmp-include=$(pwd)/gmp --with-gmp-lib=$(pwd)/gmp/.libs \
    --without-ppl --without-cloog

When I attempt to make I get the error (after digging around in config.logs):

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

I have gmp in a subdirectory and got to this point after successfully compiling it. How can I point GCC to use this library?

I'm going through LFS in an attempt to get myself more familiar with Linux behaviour. I've jumped over a fair few hurdles but this particular case is stumping me.

If it's relevant: I'm using an Ubuntu 11 host. Any ideas?

With thanks.

2 Answers 2


Add the path to GMP using the below switch, add that to your configure statement.

  • If I'm reading the configuration docs correctly --with-gmp is equivalent to --with-gmp-include and --with-gmp-lib (can't test this until the morning)
    – Rushyo
    Commented May 19, 2011 at 18:40
  • This is what ./configure --help says -- --with-gmp-include=PATH specify directory for installed GMP include files --with-gmp-lib=PATH specify directory for the installed GMP library so you actually need to point to the include directory and libs directory or alternately you could just point to the parent directory with the above option Commented May 20, 2011 at 0:28
  • I'm already doing so, however, as indicated.
    – Rushyo
    Commented May 20, 2011 at 6:35
  • look at your config.log and see whats going wrong, may be you should post the errors from config.log here Commented May 20, 2011 at 7:55
  • That's where the error came from... (also, tried --with-gmp instead. No change). The file does definitely exist in the location I've specified.
    – Rushyo
    Commented May 20, 2011 at 8:36

I'm fairly sure the issue was caused by my (dumb) decision to use a combined source + build directory. Cleaning up my environment and re-building to a different folder has addressed this issue.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .