GMP docs say that static binding can provide a slight performance improvement.
I had a problem with its static link libgmp to my Linux systems. I narrowed down the question I have for a tiny test.
gmptest.c
#include <gmp.h>
int main(int argc, char** argv) {
mpz_t foo;
mpz_init(foo);
return 0;
}
Makefile:
all: clean gmptest static
clean:
rm -f *.s
rm -f *.o
rm -f gmptest
rm -f static-gmptest
gmptest: Makefile gmptest.c
gcc -std=c99 -O3 -lgmp gmptest.c -o gmptest
static: clean Makefile gmptest.c
gcc -std=c99 -O3 -static /usr/lib/libgmp.a gmptest.c -o static-gmptest
The non-static binary is compiled and linked without any problems, but "Make static" produces:
gcc -std=c99 -O3 -static /usr/lib/libgmp.a gmptest.c -o static-gmptest
/tmp/ccWSFke9.o: In function `main':
gmptest.c:(.text+0x8): undefined reference to `__gmpz_init'
collect2: ld returned 1 exit status
make: *** [static] Error 1
The library exists:
chris@vostro:~/Dropbox/static$ ls -lA /usr/lib/libgmp.a
-rw-r--r-- 1 root root 1041666 2010-02-26 13:20 /usr/lib/libgmp.a
I also tried -lgmp for static binding, but the error is the same.
This is all on Ubuntu 10.04 and 10.10 AMD64.
Can someone enlighten me regarding the obvious mistake I am making?
Thank,
Chris.
source
share