[OCLUG-devel] Runtime Libraries

Christopher Smith x at xman.org
Mon Sep 12 18:12:46 PDT 2005


Doug Jolley wrote:

>
>
>
>     > Doug, I might have my terminology mixed up, but I think that
>     when you
>     > compile something even as simple as hello world, at least on
>     Linux (and
>     > I'm sure most other *NIX variants), you're using a runtime library
>     (glibc on Linux.)
>
>
> Really.  James, I'm certainly not saying that you're wrong; but, that
> would be news to me. 

Run "ldd" on your binary. Unless you explicitly used "-static" to link
statically to your libraries, chances are you'll see that it's using the
glibc runtime.

> You have said a couple of things that interest me a lot.  First, I've
> always wondered why it is that I can just include a header file and I
> seem to get the result that the whole library is included.

It's because the relevant code is included in the glibc, which is
automatically included provided you are compiling with gcc. gcc implies
you are using C, and C isn't C without the C runtime. If you use ld
directly, you need to specify all the libraries you link with.

> Are you saying that glibc is automatically included?  If so are there
> other libraries that are also automatically included?  Actually, I was
> beginning to believe that it was the C Standard Library that was
> automatically included.

Yes. glibc is the GNU implementation of the C standard libary (with some
extras).

> The other thing is that I don't think that crypt is part of glibc. 
> Does that have any effect on what you're saying?

There are two different crypt's. There's the crypt() function call, and
libcrypt, which provides a variety of cryptographic functions.

>
> Finally, I tried your suggestion of adding a compiler option
> -llibcrypt.  The result was a compiler complaint that llibcrypt
> couldn't be found.  The fact that the 'l' flag was included in the
> complaint concerns me (i.e., why it should be looking for llibcrypt
> instead of just libcrypt baffles me.)

You want to do "-lcrypt", the "lib" is automatically prepended.

--Chris


More information about the OCLUG-devel mailing list