1. 程式人生 > >undefined reference to `log' 問題解決

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 調整編譯器問題解決。