我正在尝试编译一个使用 GMP 库中的许多函数的 C 程序 (gfp2.c)。我使用正常的配置、制作和安装顺序下载并安装了 GMP 库。我还在安装前运行了 make check 并且没有错误。
我正在使用 GMP 5.1.1、GCC 4.2.1 和 MAC OS 10.8.2。
我首先键入gcc gfp2.c -lgmp
链接库,然后尝试gcc gfp2.c
在终端上获取以下输出:
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
我对 C 编程和使用库等很陌生,真的不知道我在做什么,所以任何帮助表示赞赏。谢谢!