2
Good evening, when I try to use some function of Math. h and put as argument a variable and try to compile I get an error. Can you explain to me why this is happening?
Follow an example code:
#include <stdio.h>
#include <math.h>
int main(){
int cacheSize = 4;
int memSize = 16;
// log de cacheSize na base 2
double cacheBits = 0;
cacheBits = log(cacheSize)/log(2);
// log de memSize na base 2
double memBits = 0;
memBits = log(memSize)/log(2);
return 0;
}
The error message I get:
gcc teste.c -o teste
/usr/bin/ld: /tmp/ccHF5avR.o: na função "main":
teste.c:(.text+0x25): referência não definida para "log"
/usr/bin/ld: teste.c:(.text+0x51): referência não definida para "log"
collect2: error: ld returned 1 exit status