sqrt(x)

tobaccofarm phaceton@gmail.com
Sun May 15 15:50:00 GMT 2005


Hello,

I tried to compile the following simple c program:


-------------------------------------------------------------------------
#include <stdio.h>
#include <math.h>

main()
{
   double x, y, z;

   x = 64.0;
   y = 3.0;
   z = 0.5;
   printf("pow(64.0, 3.0) returns: %7.0f\n", pow(x, y));
   printf("sqrt(64.0) returns:         %2.0f\n", sqrt(x));
   printf("pow(64.0, 0.5) returns: %2.0f\n", pow(x, z));
   return 0;
}

------------------------------------------------------------------------

However the compiler gave the following error messages:

sqrt.c:15:2: warning: no newline at end of file
/tmp/ccCL96r1.o(.text+0x4d): In function `main':
sqrt.c: undefined reference to `pow'
/tmp/ccCL96r1.o(.text+0x80):sqrt.c: undefined reference to `sqrt'
/tmp/ccCL96r1.o(.text+0xc0):sqrt.c: undefined reference to `pow'
collect2: ld returned 1 exit status


gcc  -v gives:

Reading specs from /usr/lib64/gcc-lib/x86_64-suse-linux/3.3.5/specs
Configured with: ../configure --enable-threads=posix --prefix=/usr
--with-local-prefix=/usr/local --infodir=/usr/share/info
--mandir=/usr/share/man --enable-languages=c,c++,f77,objc,java,ada
--disable-checking --libdir=/usr/lib64 --enable-libgcj
--with-slibdir=/lib64 --with-system-zlib --enable-shared
--enable-__cxa_atexit x86_64-suse-linux
Thread model: posix
gcc version 3.3.5 20050117 (prerelease) (SUSE Linux)

I tried to compile the above c file on knoppix 2.8.2,the same error message
was displayed.



More information about the Gcc-help mailing list