Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've coded a project with some files in C. To make it easy for the user to start the program I started to generate a cfg-file. For this reason I installed libconf. Unfortunately on compiling with a example file of libconfig I get this message.

gcc $(pkg-config --cflags --libs libconfig) example1.c -o example1 example.cfg

example1.c: In Function »main«: example1.c:43:13: Warning: Format »%s« expected argumenttyp »char *«, but argument 3   has typ »int« [-Wformat]


As I got told I installed sudo apt-get install libconfig8-dev and was hoping not setting up any PKG_CONFIG_PATH. It looks like it's not compiling correct.

share|improve this question
I found that the .pc files are stored in /usr/lib/pkgconfig but how can I set it up in the enviroment variable PKG_CONFIG_PATH – Fendrix Sep 13 '12 at 13:55
It is a malformed idea to think that you have to set PKG_CONFIG_PATH to fix this problem. Fendrix, you do not have to do that. The error message is a bit misleading. You should read my answer. – allquixotic Sep 13 '12 at 13:56
I just put the command gcc pkg-config --cflags libconfig configTest.c -o configTest and it compiled.... hope it runs ... if so thank u very much allquixotic – Fendrix Sep 13 '12 at 14:41
I would suggest revising your compile command as follows: gcc $(pkg-config --cflags --libs libconfig configTest.c -o configTest` – allquixotic Sep 13 '12 at 14:44
Err, gcc $(pkg-config --cflags --libs libconfig) configTest.c -o configTest – allquixotic Sep 13 '12 at 15:04
up vote 1 down vote accepted

How did you obtain and install libconfig?

If you just installed the libconfig8 package, that is not enough. You also need to install the -dev package corresponding to it, in order to provide the development files (headers, static link library, and pkg-config data). I was able to find that for libconfig for precise on So

sudo apt-get install libconfig8-dev

should do the trick.

As you can see from here, the file list for this package contains the following file path:


This is precisely the file that pkg-config needs to be able to pull out the CFLAGS and LDFLAGS corresponding to libconfig.

This directory is on the "built-in' pkg-config search path out of the box on Ubuntu. For this reason, it is not necessary to set PKG_CONFIG_PATH. You would only ever set that environment variable if you need pkg-config to look in directories other than those which it searches by default. So if you compiled a program and installed it in /home/user/apps/blah and the file /home/user/apps/blah/lib/pkg-config/libblah.pc needed to be available to pkg-config, you would set:

export PKG_CONFIG_PATH=/home/user/apps/blah/lib/pkg-config/libblah.pc

to make pkg-config find that installation of libblah.pc.

However, since you are installing libconfig from Ubuntu itself, it will automatically "plunk" the .pc file in the correct search directory.

share|improve this answer
thanks a lot... nearly got it ... now I don't get the enviroment error message any more but still on compiling gcc pkg-config --cflags libconfig configTest.c -o configTest pkg-config --libs libconfig... it says pkg-config not found libconfig not found and --libs not recognized – Fendrix Sep 13 '12 at 14:18
Please edit your original question indicating the exact input you get, and the output. Also be aware that the second call to pkg-config in your command line needs to be in backticks (`) or in a $() statement. – allquixotic Sep 13 '12 at 14:23

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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