Runtime error

Federico Stra feddy.stra at
Tue Jun 29 15:24:21 CEST 2010

Hello everybody,
I need help for I experience some troubles running programs compiled with the -lgmp option to link them to the libgmp library.

I installed gmp-5.0.1 by executing (as written in the manual):
   make check
   make install

As a result, the following files have been added to /usr/local/lib:
   federico at federico-laptop:~$ ls /usr/local/lib/libgmp* -l
   -rw-r--r-- 1 root root 814790 2010-06-29 13:59 /usr/local/lib/libgmp.a
   -rwxr-xr-x 1 root root    917 2010-06-29 13:59 /usr/local/lib/
   lrwxrwxrwx 1 root root     16 2010-06-29 13:59 /usr/local/lib/ ->
   lrwxrwxrwx 1 root root     16 2010-06-29 13:59 /usr/local/lib/ ->
   -rwxr-xr-x 1 root root 450955 2010-06-29 13:59 /usr/local/lib/

Now, I create a file main.c:
   #include <stdio.h>
   #include <gmp.h>
   int main() {

I compile it with the following command:
   gcc main.c -o main -lgmp

On execution, the program exits with the following error:
   federico at federico-laptop:~$ ./main
   ./main: error while loading shared libraries: cannot open shared object file: No such file or directory

That seems to me a bit strange...
Anyway, if I compile the program with
    gcc main.c -o main -lgmp -static
instead, then it runs properly, because it doesn't need to link them upon runtime.
Is there any reason for this behavior? Shall I try to copy the libraries to /usr/lib, maybe?

Thank you in advance.
Hotmail: Trusted email with powerful SPAM protection.

More information about the gmp-discuss mailing list