Russel
Russel

Reputation: 3729

Libraries for standard stuff (ie: cout, etc) *NEWBIE QUESTIONS* :)

I was wondering about the standard C libraries that contain all the functions/definitions like abs(), cout streams, printf, etc.

I'm familiar with the header files (stdio.h, cmath.h, time.h, etc etc) but there doesn't seem to be any corresponding .lib or .dll anywhere (ie. stdio.lib, time.dll, etc).

Where is the actual code for the functions in these header files? Am I misunderstanding something? Is there like, one huge lib file that contains all the standardized stuff, or one for each header?

Any help appreciated!!

Thanks!

Upvotes: 3

Views: 321

Answers (5)

Sam Hanes
Sam Hanes

Reputation: 2839

As Arpan mentioned, you can use ldd (which is in the 'binutils' package) to discover what SO file is actually being used for libc. The most common implementation on Linux systems is the GNU C library, usually called glibc.

Upvotes: 1

Fanatic23
Fanatic23

Reputation: 3428

If you are on Linux/some variant of UNIX/AIX try using ldd . Just for the fun of trying something new type in ldd `which ls` in your Linux prompt. Here's what I got:

librt.so.1 => /lib/tls/librt.so.1 (0x0084c000)
libacl.so.1 => /lib/libacl.so.1 (0x40022000)
libselinux.so.1 => /lib/libselinux.so.1 (0x00289000)
libc.so.6 => /lib/tls/libc.so.6 (0x00a0b000)
libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00c57000)
/lib/ld-linux.so.2 (0x009ec000)
libattr.so.1 => /lib/libattr.so.1 (0x40028000)

The paths should tell you where from the shared libraries are being picked up. If you are using Windows, get hold of depends.exe http://www.dependencywalker.com -- excellent tool

Upvotes: 3

paxdiablo
paxdiablo

Reputation: 881573

You generally don't have to explicitly link the C or C++ runtime libraries in. Usually the compiler will call the linker with the correct options to do it for you.

In fact, with gcc, you have to do something to not include the default libraries (such as using -nodefaultlibs, -nostdlib or -nostartfiles).

The actual location of the standard library, including whether or not it's in a single file, is an implementation issue.

Upvotes: 2

Miro A.
Miro A.

Reputation: 7963

If you mention DLL's, I assume you are using Windows. In this case, there is usually one "runtime" DLL shipped with compiler. With Visual C++, I believe the name is msvcrt.dll or similar.

Upvotes: 0

James McNellis
James McNellis

Reputation: 355079

It depends on the implementation. On Windows, the standard library functionality is in the C and C++ runtime libraries. The C runtime library is always linked in automatically; the C++ runtime library is linked in automatically if you include one of the standard library headers.

Upvotes: 4

Related Questions