GTK+-3.0-dev No Such File Or Directory on compile (Linux Mint/gcc)

cgccgtk3linux-mint

I'm taking my first foray into C/C++/GTK, and having trouble getting a basic GTK+ program to compile. I have sample.c. If I try to compile it with

$ gcc sample.c -o sample 'pkg-config --cflags --libs gtk+-3.0'

It complains about no file or directory.

Package gtk+3.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `gtk+3.0.pc'
to the PKG_CONFIG_PATH environment variable
No package 'gtk+3.0' found

To troubleshoot, I have tried:

$ gcc sample.c -o sample

I get gtk/gtk.h No Such File Or Directory, obviously.

When I try

$ pkg-config --cflags gtk+-3.0

I get

-pthread -I/usr/include/gtk-3.0 -I/usr/include/atk-1.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/pango-1.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/cairo -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/harfbuzz -I/usr/include/freetype2 -I/usr/include/pixman-1 -I/usr/include/libpng12 

and

$ pkg-config --libs gtk+-3.0

gives me this:

Package gtk+3.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `gtk+3.0.pc'
to the PKG_CONFIG_PATH environment variable
No package 'gtk+3.0' found

I am using a fresh install of Mint 15, and I have libgtk-3-dev installed via the package manager, dependencies are satisfied. I know its basic, but I can't quite wrap my head around what I need to do.

EDIT
Since the above post, I've installed the gtk+3.0 package (installs a bunch of other packages), and now I get this:

$ pkg-config --libs gtk+-3.0

-lgtk-3 -lgdk-3 -latk-1.0 -lgio-2.0 -lpangocairo-1.0 -lgdk_pixbuf-2.0 -lcairo-gobject -lpango-1.0 -lcairo -lgobject-2.0 -lglib-2.0

now I get the error

gcc: error: pkg-config --libs --cflags gtk+-3.0: No such file or directory

EDIT 2:
After screwing with it for a long time, I ran this command

$ pkg-config --libs --cflags gtk+-3.0

and copied the output into the next command:

$ gcc simple.c -o simple {pasted output of successful pkg-config command}

and the program compiled fine.

$ gcc simple.c -o simple 'pkg-config --libs --cflags gtk+-3.0'

still doesn't work though, I get the following error:

gcc: error: pkg-config --libs --cflags gtk+-3.0: No such file or directory

Solutions?

Best Answer

OK, the guys over at linuxquestions got me straightened out.

` != ' (backtick is not the same as single quote)

I should have used backticks instead of the quote, also could have used $()

$ gcc simple.c -o simple $(pkg-config --args)

I'll go read a manual on the command line... :/

as for the first problem (why pkg-config --libs gtk+-3.0) gave me a "package gtk+3.0 was not found in the pkg-config search path", I think I must have only had libgtk-3-dev installed and not installed gtk+3.0.

Related Topic