Reputation: 77
I'm trying to compile a C program (gfp2.c) that uses many functions from the GMP library. I downloaded and installed the GMP library using the normal configure, make and install sequence. I also ran make check before the install and there were no errors.
I am using GMP 5.1.1, GCC 4.2.1 and MAC OS 10.8.2.
I first type gcc gfp2.c -lgmp
to link the library and then tried gcc gfp2.c
and get the following output on the terminal:
1407-wn-172-21-30-223:pqcrypto11_scripts dfish$ gcc gfp2.c -lgmp
v1407-wn-172-21-30-223:pqcrypto11_scripts dfish$ gcc gfp2.c
Undefined symbols for architecture x86_64:
"___gmp_printf", referenced from:
_print_GF in ccrft0vq.o
"___gmp_randinit_default", referenced from:
_setup_GF in ccrft0vq.o
"___gmp_sprintf", referenced from:
_get_GF in ccrft0vq.o
"___gmpz_add", referenced from:
_add_GF in ccrft0vq.o
_mul_GF in ccrft0vq.o
_sqr_GF in ccrft0vq.o
"___gmpz_add_ui", referenced from:
_add_GF_ui in ccrft0vq.o
"___gmpz_addmul", referenced from:
_inv_GF in ccrft0vq.o
"___gmpz_clear", referenced from:
_clear_GF in ccrft0vq.o
_setup_GF in ccrft0vq.o
_free_GF in ccrft0vq.o
"___gmpz_cmp", referenced from:
_cmp_GF in ccrft0vq.o
"___gmpz_cmp_ui", referenced from:
_is_one_GF in ccrft0vq.o
"___gmpz_fdiv_ui", referenced from:
_setup_GF in ccrft0vq.o
"___gmpz_init", referenced from:
_init_GF in ccrft0vq.o
_setup_GF in ccrft0vq.o
"___gmpz_init_set_str", referenced from:
_setup_GF in ccrft0vq.o
"___gmpz_init_set_ui", referenced from:
_setup_GF in ccrft0vq.o
"___gmpz_invert", referenced from:
_inv_GF in ccrft0vq.o
_a24 in ccrft0vq.o
"___gmpz_mod", referenced from:
_add_GF in ccrft0vq.o
_add_GF_ui in ccrft0vq.o
_sub_GF in ccrft0vq.o
_sub_GF_ui in ccrft0vq.o
_scalar_GF in ccrft0vq.o
_scalar_GF_si in ccrft0vq.o
_mul_GF in ccrft0vq.o
...
"___gmpz_mul", referenced from:
_scalar_GF in ccrft0vq.o
_mul_GF in ccrft0vq.o
_sqr_GF in ccrft0vq.o
_inv_GF in ccrft0vq.o
"___gmpz_mul_2exp", referenced from:
_setup_GF in ccrft0vq.o
"___gmpz_mul_si", referenced from:
_scalar_GF_si in ccrft0vq.o
"___gmpz_neg", referenced from:
_inv_GF in ccrft0vq.o
"___gmpz_pow_ui", referenced from:
_setup_GF in ccrft0vq.o
"___gmpz_set", referenced from:
_copy_GF in ccrft0vq.o
_add_GF_ui in ccrft0vq.o
_sub_GF_ui in ccrft0vq.o
_neg_GF in ccrft0vq.o
"___gmpz_set_str", referenced from:
_set_GF in ccrft0vq.o
"___gmpz_set_ui", referenced from:
_shamir in ccrft0vq.o
_a24 in ccrft0vq.o
"___gmpz_sizeinbase", referenced from:
_mont_3ladder in ccrft0vq.o
_shamir in ccrft0vq.o
"___gmpz_sub", referenced from:
_sub_GF in ccrft0vq.o
_neg_GF in ccrft0vq.o
_mul_GF in ccrft0vq.o
_sqr_GF in ccrft0vq.o
"___gmpz_sub_ui", referenced from:
_setup_GF in ccrft0vq.o
_sub_GF_ui in ccrft0vq.o
"___gmpz_tstbit", referenced from:
_mont_3ladder in ccrft0vq.o
_shamir in ccrft0vq.o
"___gmpz_urandomm", referenced from:
_random_GF in ccrft0vq.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
I'm pretty new to C programming and using libraries, etc. and really do not know what I'm doing so any help is appreciated. Thanks!
Upvotes: 2
Views: 2078
Reputation: 570
Your first attempt has already done the compilation and the linking. You don't need to do the second step. If you check your directory you'll find a file called a.out that is the executable you need.
Upvotes: 2
Reputation: 122381
You need to link in the GMP library:
gcc gfp2.c -lgmp
(it's not clear why you got that working initially and then re-ran without the library).
Upvotes: 2