3

My sysadmin recently installed a new version of GCC, in /lusr/opt/gcc-4.4.3. I tested it as follows:

mike@canon:~$ cat test.c
int main(){
  return 0;
}
mike@canon:~$ gcc test.c
/lusr/opt/gcc-4.4.3/libexec/gcc/i686-pc-linux-gnu/4.4.3/cc1: error while loading shared libraries: libmpfr.so.1: cannot open shared object file: No such file or directory

After informing my sysadmin about this, he said to add /lusr/opt/mpfr-2.4.2/lib:/lusr/opt/gmp-4.3.2/lib to my LD_LIBRARY_PATH. After doing this, I get the following error:

mike@canon:~$ gcc test.c
cc1: error: unrecognized command line option "-L/lusr/opt/mpfr-2.4.2/lib"

First, my sysadmin wasn't entirely sure this was the best workaround(though he did say it worked for him...), so is there a better solution?

Second, why am I getting a linker error from cc, and how can I fix it?

Some information which may be helpful:

mike@canon:~$ env | grep mpfr
OLDPWD=/lusr/opt/mpfr-2.4.2/lib
LD_LIBRARY_PATH=/lusr/opt/mpfr-2.4.2/lib:/lusr/opt/gmp-4.3.2/lib:

mike@canon:~$ echo $LDFLAGS

(the above is a blank line)
Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
Mike
  • 23,892
  • 18
  • 70
  • 90
  • @Peter: Clearly, a 32-bit Linux on Intel - witness the pathname used in the path to `cc1`. If you're asking which Linux distro, that is a different issue - though it shouldn't be a critical problem. – Jonathan Leffler Jan 23 '11 at 20:32
  • @Jonathan Leffler: Given that his installation is busted, perhaps that shouldn't be trusted. – Peter Eisentraut Jan 23 '11 at 21:20
  • @Peter: maybe not...it would do no harm to have the information. But the compiler is now running enough that the o/s must be compatible enough with Linux that it probably is some variant of Linux. Ultimately, it won't make much difference - he probably needs a rebuilt GCC - but including version and platform information is usually a good idea. – Jonathan Leffler Jan 23 '11 at 21:53

2 Answers2

1

I would suggest that your sysadmin needs to install the GMP and MPFR libraries from the build machine into the same location on your machine. (There's also the MPC library which you may also need.) Alternatively, your sysadmin needs to install a rebuild of GCC - preferably version 4.5.2 since that is (AFAIK) current - with the correct settings for where the GMP and MPFR libraries will be installed on your machine.

You shouldn't need to set LD_LIBRARY_PATH to use GCC. If you need to do so, it indicates that it was not built for the machine where it is running. Key libraries are missing.

To go further with your debugging, you probably need to use:

gcc -v test.c

This will show you the command lines executed. There is no call for the -L option (which affects the way programs are linked) to be passed to the phase 1 compiler.

Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
0

This looks like some buggy argument parsing by gcc (it shouldn't complain about -Lfoo).

Can you try setting

LD_LIBRARY_PATH=\ /lusr/opt/mpfr-2.4.2/lib:/lusr/opt/gmp-4.3.2/lib

so that there's a leading space before that mpfr library path?

Nick Dixon
  • 865
  • 5
  • 9
  • The leading space doesn't seem to have any effect. echo $LD_LIBRARY path doesn't seem to have changed either. – Mike Feb 12 '10 at 20:18