Alex Rivera | Logout

GCC -lm -lz -lrt options - what are they about?

Asked 2011-04-14T12:18:07.517
27

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 standard math library or what?

-lz for compression? What compression?

And I don't have any idea what -lrt is.


What are these things?

  • math library. Is it the same that we use when we include <cmath> or <math.h>?
  • compress library. What does this mean? Does it provide some tools that we can use to compress files, or does it help the compiler/linker to do some compress things?
Edit
Report

2 Answers

7

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.

answered 2011-04-14T12:26:16.073
1

All of them are standard C as far as I know, probably included in libstdc++ (your question is tagged C++).

answered 2011-04-14T12:32:25.407

Your Answer