Wednesday, April 16, 2008

compile problem of C program on linux

undefined reference to `sqrt' undefined reference to `pow'

add –lm, means to link the math library.
So the compile command is gcc -lm your_program.c –o your_program.

undefined reference to `strupr'
Because standard "string.h" doesn't have strupr function,
you have to write the function to be strupr.

Ex.
#include
void make_upper_case(char *s)
{
while (*s)
{
*s = toupper((unsigned char) *s);
s++;
}
}

No comments:

Clicky

Clicky Web Analytics