olddays Posted December 21, 2006 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? Link to comment Share on other sites More sharing options...
ilia_kr Posted December 21, 2006 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 Link to comment Share on other sites More sharing options...
olddays Posted December 21, 2006 Author Share Posted December 21, 2006 I didn't understrand what you have written as code? What you mean by file.name your-code?? Link to comment Share on other sites More sharing options...
ilia_kr Posted December 21, 2006 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]$ Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now