C libs

Programming languages, Coding, executables, and scripting.
Post Reply
Message
Author
Linlord
Posts: 16
Joined: 2004-03-06 12:50
Location: 127.0.0.1

C libs

#1 Post by Linlord »

Can somebody tell me where the C compilere looks for the C library?

lacek
Posts: 769
Joined: 2004-03-11 18:49
Location: Budapest, Hungary
Contact:

#2 Post by lacek »

It is located in /usr/lib, called libc6.so, and linked to the program automatically.

Linlord
Posts: 16
Joined: 2004-03-06 12:50
Location: 127.0.0.1

#3 Post by Linlord »

Thanx !!

So when I want to add libs,Ihave to place them in this directory?

lacek
Posts: 769
Joined: 2004-03-11 18:49
Location: Budapest, Hungary
Contact:

#4 Post by lacek »

No, you don't, and it is usually a bad idea to put files to a location to which the installer supposed to put some. In the end, you won't remember which is safe to delete if it isn't needed and which is required.
The libs are searched this way:
First, there is a shell variable called LD_LIBRARY_PATH. If it is exported, then the compiler (and the system in general) will search for libs in this path.
There is a file in /etc called ld.so.conf. It contains paths, one in a line. When the 'ldconfig' command called, it builds a 'library cache'. If the lib wasn't found in LD_LIBRARY_PATH, this cache is searched.
If the lib still not found, it is searched in /usr/lib and in /lib.

For more info, see the man page of ld.so, ldconfig, and ldd.

Post Reply