u04f061
Advanced Member level 4
+undefined reference to log2 +lm
i am using ubuntu and gcc for c compiling. i have designed the following program,
#include <stdio.h>
#include <math.h>
int main(void){
float x=10.0;
float y=30.0;
printf("\n %f \t %f \t %1f",log(x),log2(x),sqrt);
return 0;
}
this is the command line result of gcc
ejaz@msiddique:~/cproj$ gcc -o math math.c
math.c: In function ‘main’:
math.c:6: warning: incompatible implicit declaration of built-in function ‘log2’/tmp/ccLMCrbz.o: In function `main':math.c.text+0x4d): undefined reference to `sqrt'
:math.c.text+0x61): undefined reference to `log2'
:math.c.text+0x6f): undefined reference to `log'
collect2: ld returned 1 exit status
ejaz@msiddique:~/cproj$
please help me in solving this trouble
i am using ubuntu and gcc for c compiling. i have designed the following program,
#include <stdio.h>
#include <math.h>
int main(void){
float x=10.0;
float y=30.0;
printf("\n %f \t %f \t %1f",log(x),log2(x),sqrt);
return 0;
}
this is the command line result of gcc
ejaz@msiddique:~/cproj$ gcc -o math math.c
math.c: In function ‘main’:
math.c:6: warning: incompatible implicit declaration of built-in function ‘log2’/tmp/ccLMCrbz.o: In function `main':math.c.text+0x4d): undefined reference to `sqrt'
:math.c.text+0x61): undefined reference to `log2'
:math.c.text+0x6f): undefined reference to `log'
collect2: ld returned 1 exit status
ejaz@msiddique:~/cproj$
please help me in solving this trouble