未定义的引用`log'

Sha*_*ade 28 c random math makefile ld

我正在尝试编译Donald Eastlake的RFC 3797随机选择算法的实现(代码:http://kambing.ui.ac.id/minix/other/rfc3797/).但是,我收到链接器错误:

rfc3797.c:(.text+0xe7f): undefined reference to `log'
Run Code Online (Sandbox Code Playgroud)

我试图用提供的Makefile来实现它,它明确地链接到数学图书馆,但我仍然得到错误:

cc -lm -o randomselection rfc3797.c MD5.c
Run Code Online (Sandbox Code Playgroud)

我该如何编译这个程序?

faj*_*ran 38

我不知道原因是什么,但如果你-lm走到最后,它会编译.

$ cc -o randomselection rfc3797.c MD5.c -lm
rfc3797.c: In function ‘getinteger’:
rfc3797.c:183:3: warning: format not a string literal and no format arguments [-Wformat-security]
Run Code Online (Sandbox Code Playgroud)

  • 如果你考虑如何完成链接库,原因是相当直截了当的. (4认同)