gmp shared libraries not found
I have a very simple GMP program in C (below)
#include <stdio.h>
#include <gmp.h>
int ma开发者_高级运维in() {
mpf_t a, b, inter;
mpf_init(a);
mpf_init(b);
mpf_init(inter);
mpf_set_d(a, 3.0);
mpf_set_d(b, 5.0);
mpf_add(inter, a, b);
gmp_printf("%F+%F=%F\n", a, b, inter);
}
For some reason, it compiles alright, but when run, it produces
error while loading shared libraries: libgmp.so.10: cannot open shared object file: No such file or directory
What's wrong?
It would appear /usr/local/lib
is not in /etc/ld.so.conf
or /etc/ld.so.conf.d/*
.
If it is simply run sudo ldconfig
(or ldconfig
as root) and try again.
If it is not, either add it or manually override the library path for the command:
LD_LIBRARY_PATH=/usr/local/lib ./myprogram
It does seem your configuration is strange, check that /usr/local/lib/libgmp.so.10
is a link to /usr/local/lib/libgmp.so.10.0.2
, e.g.
$ ls -ltr /usr/lib/libgmp.so.3
lrwxrwxrwx 1 root root 15 2011-07-27 12:15 /usr/lib/libgmp.so.3 -> libgmp.so.3.5.2
精彩评论