C libs

Need help with C, C++, perl, python, etc?

C libs

Postby Linlord » 2004-03-12 06:05

Can somebody tell me where the C compilere looks for the C library?
Linlord
 
Posts: 16
Joined: 2004-03-06 12:50
Location: 127.0.0.1

Postby lacek » 2004-03-12 10:10

It is located in /usr/lib, called libc6.so, and linked to the program automatically.
lacek
Moderator Team Member
 
Posts: 769
Joined: 2004-03-11 18:49
Location: Budapest, Hungary

Postby Linlord » 2004-03-12 20:48

Thanx !!

So when I want to add libs,Ihave to place them in this directory?
Linlord
 
Posts: 16
Joined: 2004-03-06 12:50
Location: 127.0.0.1

Postby lacek » 2004-03-16 10:54

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.
lacek
Moderator Team Member
 
Posts: 769
Joined: 2004-03-11 18:49
Location: Budapest, Hungary


Return to Programming

Who is online

Users browsing this forum: No registered users and 5 guests

fashionable