【发布时间】:2018-03-16 20:58:37
【问题描述】:
我不知道为什么会出现这些编译错误:
gcc -o Compil obj/MillerRabin.o obj/main.o -L. -L/usr/lib/ -Wl,-rpath=/home/---------/Documents/AC20_Cyrpto -lgmp -lCommon -ltest -lprimeGen
./libtest.so: undefined reference to `__gmpz_set_str'
./libtest.so: undefined reference to `__gmpz_set_ui'
./libtest.so: undefined reference to `__gmpz_add_ui'
./libtest.so: undefined reference to `__gmpz_clear'
./libtest.so: undefined reference to `__gmpz_init'
./libtest.so: undefined reference to `mpzPrint'
collect2: error: ld returned 1 exit status
Makefile:61: recipe for target 'Compil' failed
make: *** [Compil] Error 1
这些错误来自libs/test/test.c,我使用的是我朋友制作的 make 文件,我还没有真正研究它们是如何工作的。
奇怪的是,在我的 libs 文件夹中,我还有另一个使用 gmp 的 .c 文件(libs/Common/common.h 和 mpzfunctions.c),而且那个文件没有给我任何错误。如果我将我的测试函数移到主函数,则编译工作正常。
如果有人知道如何解决这个问题,那就太好了!谢谢。
【问题讨论】:
标签: c makefile compilation undefined