I
I
Ivan2017-09-26 20:03:00
linux
Ivan, 2017-09-26 20:03:00

What is the linker complaining about?

I'm trying to build a program in C (without pluses) using the GMP library:

gcc -g -L/usr/lib/x86_64-linux-gnu/ -llibgmp main.c

I get an error:
/usr/bin/ld: cannot find -llibgmp
I don’t understand why this is so, because the library clearly exists and the linker knows about it:
$ readlink /usr/lib/x86_64-linux-gnu/libgmp.so
libgmp.so.10.3.0
$ ldconfig -p | grep libgmp
  libgmpxx.so.4 (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libgmpxx.so.4
  libgmpxx.so (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libgmpxx.so
  libgmp.so.10 (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libgmp.so.10
  libgmp.so (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libgmp.so
$ gcc --version
gcc (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Ivan, 2017-09-27
@32seph

In general, apparently something was crooked in Ubuntu. The problem is solved by downloading the original library from gmplib.org.

C
CityCat4, 2017-09-26
@CityCat4

You told the linker to look for the liblibgmp.so library :) Out of the blue? The linker is smart, it knows that library names start with "lib..." and therefore automatically appends that to the key value. And of course you don’t have the liblibgmp.so file :)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question