Hi,

I have encountered a problem that is undoubtedly a reflection
of my ignorance of Linux.  In attempting to compile the following
simple C program:

#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <unistd.h>

int main (int argc, char ** argv)
{
double x=102.3;

printf("square root of %f is %f\n",x,sqrt(x));
return(1);

}

with the following statement:


gcc -Wall -D_GNU_SOURCE testsqrt.c -o testsqrt.o



I get these messages:


/tmp/ccLhrAjI.o(.text+0x2b): In function `main':
: undefined reference to `sqrt'
collect2: ld returned 1 exit status

According to the man page math.h is the correct header.
Do I need to explicitly include a statement to the linker
for the math library ?  If so, which is the appropriate
lib ?  I have looked at libm.a (with ar -t) and don't find
a sqrt.o in it (though there are several modules with sqrt
within the name).

I am running a workstation install of RH9 - essentially
right out of the box.  After I first encountered this message
I did run up2date for the 3 RPMs dealing with glibc, but that
didn't change things.  Otherwise everything is as it came off
the install CDs.

Any help would be appreciated.

Thanks,

Buz Davis

_________________________________________________________________
Add photos to your messages with MSN 8. Get 2 months FREE*. http://join.msn.com/?page=features/featuredemail



-- redhat-list mailing list unsubscribe mailto:[EMAIL PROTECTED] https://www.redhat.com/mailman/listinfo/redhat-list

Reply via email to