I'd like to use pkg-config to change the include dirs for a package, but it looks like it doesn't accept any options.

After issuing the following command:

pkg-config --cflags ImageMagick -fopenmp -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16 -I/usr/include/x86_64-linux-gnu/ImageMagick-6 -I/usr/include/ImageMagick-6

...it instantly fails right at the first cflag option:

Unknown option -fopenmp

Is this a normal behavior? How can I make it work?

PS: Using Debian Jessie.


pkg-config outputs flags intended to be used with a compiler or linker. Typically you’d use it like this:

gcc $(pkg-config --cflags ImageMagick) …

You can’t use the pkg-config command to change the paths used by a given package. The paths are defined in the corresponding .pc file, e.g. /usr/lib/x86_64-linux-gnu/pkgconfig/ImageMagick.pc. To customize that, the safest option is to copy that file somewhere else, modify it as appropriate, and specify the path to the file using the PKG_CONFIG_PATH environment variable.

Note that if you built the ImageMagick libraries yourself, the build should have produced a valid .pc file for you. You also shouldn’t use .pc files to specify options such as -fopenmp; those shouldngo in your build command, in your makefile or in the CPPFLAGS, CFLAGS or CXXFLAGS environment variables (or makefile variables).

  • Thanks, It wasn't clear at first glance. In fact, I'm trying to compile a program that uses the imagemagick libraries, but some of the headers can be found in a different location (that's why I'm trying to change the path in particular). Unfortunately, the build doesn't producing any .pc files, and I have no idea how make make search for that header file in a another directory (nor how the .pc syntax works). – Gergely Lukacsy Apr 13 '17 at 14:07
  • I recommend asking another question explaining what your end goal is, proceeding in this way is probably barking up the wrong tree! – Stephen Kitt Apr 13 '17 at 14:17
  • That's what I'm going to do, thanks again for your time! – Gergely Lukacsy Apr 13 '17 at 14:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.