This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
linking doesn't work properly ?!
- To: egcs at egcs dot cygnus dot com
- Subject: linking doesn't work properly ?!
- From: Ahmed El-Mahmoudy <goofy at goofy dot dhis dot org>
- Date: Sun, 10 Oct 1999 19:34:12 +0200 (EET)
- Reply-To: amcons at ritsec3 dot com dot eg
as-salam alikom everyone,
I have a wierd problem with the GNU compiler, the following code compiles
fine when I compile it using the "g++ foo.c" :
/* cosc.c code */
#include <stdio.h>
#include <math.h>
int main(void) {
printf("cos(3.14) = %-8.2f\n", cos(3.14));
return(0);
}
while it gives me this error if I try to compile it using the command
"gcc cosc.c" :
/tmp/ccCbmYWU.o: In function `main':
/tmp/ccCbmYWU.o(.text+0x19): undefined reference to `cos'
collect2: ld returned 1 exit status
but if I compile it using the following commands it compiles well :
gcc -c cosc.c
gcc -lm cosc.o
and it also compiles fine if I compile it using the command "gcc -lm cosc.c"
I was wondering if anyone knows why this is happening ?
Thanks in advance...
+-----------------------------------------------------+
| Ahmed El-Mahmoudy |
| |
| Web : http://www.geocities.com/CapeCanaveral/9568/ |
| Snail mail : P.O. Box 10 Saray Elkobba, |
| Cairo ,Egypt. |
| Postal Code 11712 |
+-----------------------------------------------------+