-lm
is a linker flag. It should appear at the end of the linker command:
$(CC) -v -o $@ $@.o $(ARFILE) ../cosi_rand/random.a -lm
Apparently some compilers permit -l
to appear anywhere. I still haven't found out which ones do, but my GCC wants them at the end, and in reverse order of dependency: if random.a
needs libm
, then libm
should be linked in after random.a
.
I also removed $(CFLAGS)
from the linker command because you should pass linker options, not compiler options, when linking.