I know, that these are some common/basic libraries, but what do they mean exactly?
For example, I know, that -lm
is some math library, but is this the st
The answers above are all correct. The one thing I would add, being a C novice myself, is that the -l
argument tells the compiler to link your code with some library.
The confusion for me and probably others is that there is no space when calling the -l
plus the name of the lib. so -lz
, you are linking to the "z"
Note that these libraries are installed in your system. Either they came with the distro you are using, or you installed using a package manager or compiled from source (make
, make install
...).
Since those are very basic (and old) library APIS, they have very short names. As you progress and install specific libs in your system, you see more verbose names tagging the -l
there.
-lz
- is zlib, http://zlib.net/-lm
- is the math library as you've worked out (implementation defined AFAIK)-lrt
- provides POSIX realtime extensions: http://www.s-gms.ms.edus.si/cgi-bin/man-cgi?librt+3LIBlibm http://refspecs.freestandards.org/LSB_3.0.0/LSB-Core-generic/LSB-Core-generic/libm.html
libz http://refspecs.freestandards.org/LSB_3.0.0/LSB-Core-generic/LSB-Core-generic/libzman.html
librt http://www.rdg.ac.uk:8081/cgi-bin/cgiwrap/wsi14/poplog/man/3LIB/librt
All of them are standard C afaik, probably included in libstdc++ (your question is tagged C++).
-lz links to the zlib, -lm to the math and -lrt to the realtime extensions library.
The switch -lX generally means to load the library libX.so.
libm is the standard math library; it contains sin(), cos(), atanh(), all that good stuff.
libz is Zlib, a compression library which can do gzip, deflate, and a few other formats.
There are a couple of different librt's out there: one is the POSIX realtime extensions; another is a library of general-purpose programming aids.