I'm trying to create a Makefile to compile my project. However, when I use the 'math.h' library, my make fails. This is the Makefile file :
run: tema1
./tema1
build: tema1.c
gcc tema1.c -o tema1 -lm
clean:
rm *.o tema1
The part of the code where I use the pow() and sqrt() is :
float score = sqrt(k) + pow(1.25, completed_lines);
But, even compiling using '-lm', I still get this error :
> /tmp/ccSQVWNy.o: In function `easy_win_score': tema1.c:(.text+0x1518):
> undefined reference to `sqrt' tema1.c:(.text+0x1540): undefined
> reference to `pow' collect2: error: ld returned 1 exit status
> <builtin>: recipe for target 'tema1' failed make: *** [tema1] Error 1
Any idea why and how can I fix this ? If I only use this in the terminal :
gcc tema1.c -o tema1 -lm
it works, but in the Makefile, it fails.