What's the point of linking libraries

In GCC, you can link libraries using the -l flag followed by the library name. What's the point of doing this when you have already #included the header of the library in your code?

Also what does "pkg-config" do in gcc?
Last edited on
In GCC, you can link libraries using the -l flag followed by the library name. What's the point of doing this when you have already #included the header of the library in your code?

Because including a header file, and linking a library, achieve different things.

One is a preprocessor directive, that includes the text of one file in another when constructing a translation unit prior to compilation.

The other links together binary object files to make an executable that includes code compiled from multiple translation units.

Also what does "pkg-config" do in gcc?


https://lmgtfy.com/?q=gcc+pkg-config
Last edited on
Registered users can post here. Sign in or register to post.