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

后端 未结 5 1055
猫巷女王i
猫巷女王i 2021-02-12 13:36

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

5条回答
  •  猫巷女王i
    2021-02-12 14:07

    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.

提交回复
热议问题