What is the linux command that gives the paths to libraries for linking during c++ compilation?

118 views Asked by At

I remember seeing some command that works like this:

g++ main.cpp `some_forgotten_command --some_forgotten_options some_library`

When the command is run, it will substitute the part enclosed by `` with -I/path/to/some_library/include and -L/path/to/some_library/lib/ (or something similar, I don't remember exactly). However I could not remember what some_forgotten_command is.

1

There are 1 answers

4
HolyBlackCat On BEST ANSWER

It's pkgconf or pkg-config (those are two different implementations that do mostly the same thing).

pkgconf --libs LibraryName gives linker flags, and pkgconf --cflags LibraryName gives compiler flags.

You can use both --libs and --cflags in the same command (in your specific example, since you do compilation and linking together in a single command, you should use both).

And pkgconf --list-all prints a list of all installed library names.