简体   繁体   中英

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?

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.

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM