I've been trying to build some code that uses math functions (e.g. pow
).
math.h
is included, and the flag -lm
is used during the build.
When compilation is called like this (-lm
flag at the begining of the command), it failed, saying that there is an undefined reference to pow
:
gcc -lm -O3 main.o clustering.o grassberger.o hash.o list.o mat.o metropolis.o motif_ids.o output.o permutation.o prob.o random.o results.o role.o stubs.o switches.o -o mfinder
main.o: In function `get_sn_motif_id':
main.c:(.text+0x28d): undefined reference to `pow'
And when the -lm
flag is put at the end of the comand, it works!
gcc -O3 main.o clustering.o grassberger.o hash.o list.o mat.o metropolis.o motif_ids.o output.o permutation.o prob.o random.o results.o role.o stubs.o switches.o -o mfinder -lm
Is this normal?