Tuukka Toivonen wrote:
>
> >> the sqrt() function. Now, I am inlcuding the <math.h> library but I am
>
> Actually, math.h is just a header file.
>
> >You have to specify the math library that you want the compiler to
> >search,
> >either "/usr/lib/libm.a" (static library), or "/usr/lib/libm.so" (shared
> >library).
> >
> >The following should suffice:
> >
> >$ gcc -o fubar fubar.c /usr/lib/libm.so
>
> Hmm. I don't know if that works but at least it isn't the common way.
> Use rather
> gcc -o fubar fubar.c -lm
> or (to use static linking)
> gcc -static -o fubar fubar.c -lm
>
> If you'd want to specify the library path, you could use
> gcc -o fubar fubar.c -lm -L/lib
> (usually shared libm.so is in /lib directory)
>
> --
Both methods are correct. In my example I specified the exact path to
the library that you wish to use, $ gcc -o fubar fubar.c
/usr/lib/libm.so, which works fine provided the library is in the path
specified, if not then specify the path on your particular system.
$ gcc -o fubar fubar.c -lm is jjust the shorthand way of doing the same
thing. It might also have the added advantage in that it automatically
selects the shared library over the static one. (unless you want to link
to the static) in which case you specify the direct path to the static
library or, apply the option "-static" , as you showed in your exapmle.
Either way is correct, and it is mainly a matter of preference, although
in some intances one method may have advantages over another.
/John
--
email: [EMAIL PROTECTED]
Local mailserver <landreau.ruffe.edu> , remote <ns.computer.net>
Smoke a Lucky Strike!