Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

automatically linking socket shared library in *nix

I am learning network programming through the sample source codes from this link http://cs.baylor.edu/~donahoo/practical/CSockets/textcode.html. During the compilation, just wondering why in Solaris environment, i have to manually link socket and nsl library in the make file but when in the linux machine, i dont need to do that ?

like image 694
Thai Tran Avatar asked Jan 17 '23 08:01

Thai Tran


1 Answers

Documentation used: http://developers.sun.com/solaris/articles/solaris_linux_app.html

This is because linux's libc, the glibc (-lc, which is linked by default to all programs) includes socket part of POSIX; and nis/nis+ dynamic libraries in linux are loaded dynamically by libc too.

But in Solaris, there are a lot of libraries with basic functionality, which are not in libc. (libc, libucb, libmalloc, libsocket, libxnet, etc). I think, it was a design solution to allow user link only parts of API he needs.

In linux there are some basic libraries outside libc too: libaio, librt, libm.

With separate library it is easier to update only some parts of system; and it is possible to have several implementations (e.g. to provide greater compatibility/workarounds with older versions of UNIX) of some libraries coexisting in same system.

This question is discussed a lot, e.g. http://web.archiveorange.com/archive/v/KcxCHdLNpD6NANxmAt3b http://mail.opensolaris.org/pipermail/opensolaris-code/2007-January/010316.html

are seriously considering folding libnsl and libsocket into libc.

It would be nice to move ONLY the current POSIX-based and other standards-based functionality (Unix98 etc.) libnsl+libsocket functions to libc and keep all the compatibilty-wrapper stuff in libnsl/libsocket to avoid that libc gets bloated with 20years of Unix backwards-compatibility workarounds

like image 153
osgx Avatar answered Jan 29 '23 10:01

osgx