Instead of
cc -g -lm -DBLITZ_HOST_IS_LITTLE_ENDIAN foo.c
Try:
cc -g -DBLITZ_HOST_IS_LITTLE_ENDIAN foo.c -lm
When the linker searches a library, it links in modules that contain definitions for previously-undefined symbols.
If the linker searches -lm
before foo.o
, then pow()
is not yet undefined. Conversely, if foo.o
comes first, it undefines pow()
, which -lm
can then resolve.
EDIT: To accomplish this advice in your makefile, make these changes:
CFLAGS=-g -DBLITZ_HOST_IS_LITTLE_ENDIAN
LDLIBS=-lm
...
asm: asm.c
$(CC) $(CFLAGS) asm.c $(LDLIBS) -o asm
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…