olddays Posted December 21, 2006 Report Share Posted December 21, 2006 I am using Mandriva 2007 I wrote a simple c program : #include <stdio.h> #include <math.h> double d,e,f; main() { double a,b,c; void hesapla(double x,double y,double z); scanf("%lf",&a); scanf("%lf",&b); scanf("%lf",&c); hesapla(a,b,c); } void hesapla(double x,double y,double z) { double delta; delta=y*y-4*x*z; if(delta==0) { d=-y/2*x; printf("delta 0 %lf",d); return; } else { if(delta>0) { d=(-y-(exp(0.5*log(delta)))/2*x); e=(-y+(exp(0.5*log(delta)))/2*x); printf("delta>0 %lf %lf",d,e); return; } else { printf("yok bi?i"); return; } } } When I use the cc command I take these errors: denklem.c:(.text+0x10c): undefined reference to `log' denklem.c:(.text+0x11c): undefined reference to `exp' denklem.c:(.text+0x13b): undefined reference to `log' denklem.c:(.text+0x14b): undefined reference to `exp' collect2: ld returned 1 exit status I thought it was because of the panthomime of math library. Why can it be? Quote Link to comment Share on other sites More sharing options...
ilia_kr Posted December 21, 2006 Report Share Posted December 21, 2006 (edited) By default GCC plugs in only the stdio.h, you should tell it to plug in other libraries. Try this: gcc -ld your-code.c -o file.name To learn more about GCC type "man gcc". Edited December 21, 2006 by ilia_kr Quote Link to comment Share on other sites More sharing options...
olddays Posted December 21, 2006 Author Report Share Posted December 21, 2006 I didn't understrand what you have written as code? What you mean by file.name your-code?? Quote Link to comment Share on other sites More sharing options...
ilia_kr Posted December 21, 2006 Report Share Posted December 21, 2006 Suppose you have a file with a code you wrote, lets call it "prog.c". To compile it using GCC, you shuld type in a konsole/terminal emulator the following: gcc -ld [i]/location-of-prog.c[/i] -o [u]name-of-binary[/u] Here how i do it: [ilia@ilia-fc4 ~]$ cd /home/ilia/projects-c[ilia@ilia-fc4 projects-c]$ ls a.txt c.txt e.txt HW2.pdf mem.c new out.txt~ tri.c b.txt d.txt f.txt mem mem.o out.txt tri tri.o [ilia@ilia-fc4 projects-c]$ gcc -ld mem.c -o mem [ilia@ilia-fc4 projects-c]$ Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.