undefined reference to `log' 问题解决

尝试gcc 编译出现问题。
如:gcc -o lz77 main.o lz77.o tree.o bitio.o
bitio.o: In function `bitof':
bitio.c:(.text+0xd): undefined reference to `log'
bitio.c:(.text+0x1a): undefined reference to `ceil'
collect2: error: ld returned 1 exit status
Makefile:13: recipe for target 'lz77' failed
make: *** [lz77] Error 1
调整修改为 g++后问题消除

I am trying to compile the implementation of the RFC 3797 random selection algorithm by Donald Eastlake (code: http://kambing.ui.ac.id/minix/other/rfc3797/). However, I am getting a linker error:

rfc3797.c:(.text+0xe7f): undefined reference to `log'

I am trying to make it with the provided Makefile, which explicitly links against the math libraray, but I still get the error:

cc -lm -o randomselection rfc3797.c MD5.c

How can I compile this program?

以上是我编译时出现的问题,在stack overflow 上同样有人问:

我在makefile 调整编译器问题解决。