user1115057
user1115057

Reputation: 1885

How can I know which flags are available for GCC to link library more easily?

While reading documentation on some library, I saw that some library have some feature, like compiling program using those library more easier, with just typing '-something' in the GCC argument instead of typing the path to library or using pkg (... -- cflag --clibs).

How can I get the list of those '-something' for libraries or packages currently installed on my system?

For example, OpenGL flags: -lGLUT -lGL

They are surely stored in a GCC's config file when I use the package manager to install new library, or how GCC would know how to use them?

Upvotes: 0

Views: 686

Answers (2)

user1115057
user1115057

Reputation: 1885

I wanted to know those flag, since i didn't know what argument to gave to pkg. But i found out how it was working:

In /usr/lib/pkgconfig there is everything we need. Only put one of those file in argument, + --cflag and --clib.

(i didnt know i was suppose to look at /usr/lib/pkgconfig)

Upvotes: 0

Some programmer dude
Some programmer dude

Reputation: 409136

Those libraries are not stored in any configuration file.

If you check the GCC link options you will see an option "-l" which is used to select libraries to link with. What that option does is to look for libraries in a specified path.

If you look in the folder /usr/lib you will see a lot of files named like /usr/lib/libgtkspell.so.0.0.0. This if for a library named gtkspell. You link with it by using -lgtkspell, the linker will automatically add the other parts when searching for the file.

The pkg-config application is good for libraries that need special extra GCC flags, either when compiling (--cflags) or linking (--libs). But the actual flags pkg-config adds to the compilation/linking are just standard GCC flags.

Upvotes: 4

Related Questions