View Single Post
Old 05-10-2012, 05:18 AM   #29
geekmaster
Carpe diem, c'est la vie.
geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.
 
geekmaster's Avatar
 
Posts: 6,433
Karma: 10773668
Join Date: Nov 2011
Location: Multiverse 6627A
Device: K1 to PW3
Quote:
Originally Posted by xueyou2 View Post
I built a program which report "sqrt" is not defined.
I look up the math.h file,there is not sqrt function.
So is the tcc different from gcc in function?
Can i replace the header file in tcc with the same file in gcc?
What is difference between tcc and gcc in function?
To link the math library, use:

tccmake myprog -lm

PHP Code:
]# cat hello.c
#include <stdio.h>
#include <math.h>
int main(void) {
    
float x=144;
    
printf("x=%f, sqrt(x)=%f\n",x,sqrt(x));
    return 
0;
}
]
# tccmake hello -lm
]# ./hello
x=144.000000sqrt(x)=12.000000
]
It worked for me. You just did not link in the math library with the "-lm" parameter like I showed above...


Last edited by geekmaster; 05-10-2012 at 05:43 AM.
geekmaster is offline   Reply With Quote