Ό gcc δέν βρίσκει την sqrt()

Dempelis Nikolaos dempelis at ceid.upatras.gr
Mon Apr 26 10:06:27 EEST 2004


3exases to -lm gia na xrisimopoiisis tin biblio8iki pou exei tin sqrt()
[hlias at papaya hlias]$ gcc test.c -lm 


On Sun, 25 Apr 2004, Hlias wrote:

> Κάνω compile ένα πολύ απλό πρόγραμμα:
> 
> #include <stdio.h>
> #include <math.h>
> main()
> { double num;
>         printf("Δώσε ένα θετικό αριθμό:");
>         scanf("%lf", &num);
> 
> 
> 
>         if(num<0)
>                 printf("Λάθος είσοδος: Αριθμός αρνητικός\n");
>         else
>         printf("Η τετραγωνική ρίζα του %lf είναι %f\n", num , sqrt (num));
>         exit(0);
> }
> 
> Παίρνω στην εξοδό:
> 
> [hlias at papaya hlias]$ gcc test.c
> /tmp/cce21dty.o(.text+0x63): In function `main':
> : undefined reference to `sqrt'
> collect2: ld returned 1 exit status
> 
> Αν τρεξω gcc -v test.c παίρνω:
> 
> Reading specs from /usr/lib/gcc-lib/i486-slackware-linux/3.2.3/specs
> Configured with: ../gcc-3.2.3/configure --prefix=/usr --enable-shared
> --enable-threads=posix --enable-__cxa_atexit --disable-checking
> --with-gnu-ld --verbose --target=i486-slackware-linux
> --host=i486-slackware-linux
> Thread model: posix
> gcc version 3.2.3
> /usr/lib/gcc-lib/i486-slackware-linux/3.2.3/cc1 -lang-c -v -D__GNUC__=3
> -D__GNUC_MINOR__=2 -D__GNUC_PATCHLEVEL__=3 -D__GXX_ABI_VERSION=102
> -D__ELF__ -Dunix -D__gnu_linux__ -Dlinux -D__ELF__ -D__unix__
> -D__gnu_linux__ -D__linux__ -D__unix -D__linux -Asystem=posix
> -D__NO_INLINE__ -D__STDC_HOSTED__=1 -Acpu=i386 -Amachine=i386 -Di386
> -D__i386 -D__i386__ -D__tune_i486__ test.c -quiet -dumpbase test.c
> -version -o /tmp/cc391aIr.s
> GNU CPP version 3.2.3 (cpplib) (i386 Linux/ELF)
> GNU C version 3.2.3 (i486-slackware-linux)
>          compiled by GNU C version 3.2.3.
> ignoring nonexistent directory "/usr/i486-slackware-linux/include"
> #include "..." search starts here:
> #include <...> search starts here:
> /usr/local/include
> /usr/lib/gcc-lib/i486-slackware-linux/3.2.3/include
> /usr/include
> End of search list.
> /usr/lib/gcc-lib/i486-slackware-linux/3.2.3/../../../../i486-slackware-linux/bin/as 
> 
> 
> 
> -V -Qy -o /tmp/ccsOS4zL.o /tmp/cc391aIr.s
> GNU assembler version 2.14.90.0.6 (i486-slackware-linux) using BFD
> version 2.14.90.0.6 20030820
> /usr/lib/gcc-lib/i486-slackware-linux/3.2.3/collect2 --eh-frame-hdr -m
> elf_i386 -dynamic-linker /lib/ld-linux.so.2
> /usr/lib/gcc-lib/i486-slackware-linux/3.2.3/../../../crt1.o
> /usr/lib/gcc-lib/i486-slackware-linux/3.2.3/../../../crti.o
> /usr/lib/gcc-lib/i486-slackware-linux/3.2.3/crtbegin.o
> -L/usr/lib/gcc-lib/i486-slackware-linux/3.2.3
> -L/usr/lib/gcc-lib/i486-slackware-linux/3.2.3/../../../../i486-slackware-linux/lib 
> 
> 
> 
> -L/usr/lib/gcc-lib/i486-slackware-linux/3.2.3/../../.. /tmp/ccsOS4zL.o
> -lgcc -lgcc_eh -lc -lgcc -lgcc_eh
> /usr/lib/gcc-lib/i486-slackware-linux/3.2.3/crtend.o
> /usr/lib/gcc-lib/i486-slackware-linux/3.2.3/../../../crtn.o
> /tmp/ccsOS4zL.o(.text+0x63): In function `main':
> : undefined reference to `sqrt'
> collect2: ld returned 1 exit status
> 
> Ποιό είναι το λάθος μου;;
> 
> 
> 
> -- 
> linux-greek-users mailing list -- http://lists.hellug.gr
> 





More information about the Linux-greek-users mailing list