This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: archives and header files
- From: pkurpis at keck dot hawaii dot edu (Peter Kurpis)
- To: gcc-help at gcc dot gnu dot org
- Cc: wjoyce at bestweb dot net
- Date: Tue, 28 May 2002 10:06:49 -1000 (HST)
- Subject: Re: archives and header files
> How do I know what C library file or archive needs to be specified
> when compiling C programs (with gcc)? For example, if I want the
> math library and I use the math.h header file, I need to use the
> "-lm" option in the command line for the compiler. What are the
> names (like "m" for math) for the other header file and archives to
> use in the "-l" option? Is there a list somewhere?
>
> I've been looking through the GLIBC manual / GCC manual and I don't
> see the answer. The manuals tell you which library in terms of
> header files but not which archive contains the functions.
-lsomething looks for libsomething.a or libsomething.so in ld's
search path during linking. This search path is somewhat system dependent,
but there are usually three sources for the search path:
+ -L options on the gcc command line
+ a config file or built-in paths for ld
+ environment variables (e.g. LD_LIBRARY_PATH).
I think for Standard C programs, the standard functions are defined
in libc and libm. libc contains some additional "traditional" unix
stuff; libm is the math lib.
> A related question is: how can I find which functions are
> defined in any given archive (library) file (to approach the
> problem from the other direction)?
ldd libc.so
dump -t libc.a
See the man pages for other options. You might need to grep out the
info you need.