![]() |
| | #1 |
| Guest
Posts: n/a
| I got into trouble using the sin function from math.h and found a message on the board from someone with the same problem. The answer suggested to use the -lm which also works for me. Ofcourse I would like to know now what it does. The info pages are just to overwhelming with info for a newbie like me. |
|
| | #2 |
| Registered User Join Date: Oct 2001
Posts: 125
| the -lm option tells gcc to link (that's what the 'l' stands for) your code with the "math" (this what the math library is called) shared library. It's almost like DLL's in windows...
__________________ 1 rule of the Samurai Code: if you have nothing to say, don't say anything at all! |
| Engineer is offline | |
| | #3 |
| Guest
Posts: n/a
| Ok, thanks but that gives me another question. I do not have to to use a parameter like -ls for linking the stdio so why do i have to do this for the math and not for stdio ? I thought they were both standard functions of ANSI-C ? |
|
| | #4 |
| Registered User Join Date: Sep 2001
Posts: 132
| Hi! All non-mathematical ANSI-C functions are stored in libc.a/libc.so, which is always included automatically by gcc, the mathematical ANSI-C functions are stored in libm.a/libm.so, which is available if you install gcc, but is not automagically included like the MS and Borland compiler. Those compilers try to guess whether the math library is needed... The Borland compiler used to get it wrong sometimes, which they fixed in the newest version. The MS compiles used to get it right, but the latest MS compilers have this problem: Code: #include <stdio.h>
#include <math.h>
main()
{
printf("%e\n", 1.0);
}
alex |
| alex is offline | |
| | #5 |
| Guest
Posts: n/a
| Thanks! Thats the stuff I want to know |
|
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| help displaying info from structure | kisiellll | C Programming | 6 | 04-04-2009 12:51 PM |
| Question about getting an info class from another Form | Joelito | C# Programming | 0 | 10-16-2006 01:02 PM |
| Help doing an e-mail program in c... | Tyler_Durden | C Programming | 88 | 01-02-2005 03:12 PM |
| Binary trees search problem... | Umoniel | C Programming | 2 | 02-22-2004 02:29 PM |
| Guys, I really, REALLY need your help getting info into a structure. (Please help!) | Desperado | C Programming | 3 | 12-06-2001 05:30 AM |