unable to link in gtk+ libs with pkg-config

Hello,

I'm trying to teach myself how to create graphical applications using gtk+, but can't seem to even make it through step 1 of the tutorial:

http://library.gnome.org/devel/gtk-tutorial/stable/

I've been searching online, digging through man pages, and trying various experiments to see if I could figure it out myself, but after several days of trying am at the end of my rope. I'm really hoping someone here can show me the error of my ways.

I'm running FreeBSD 8.0. I thought the problem might be something I did to screw up the system, so I even tried a fresh install from the CD (I'm running FreeBSD inside a virtual machine using VirtualBox). On the fresh install, I installed gtk+ as a package, along with all the dependencies, using sysinstall.

My problem is that when I try to compile the "getting started" program (base.c), I get the following error:
Code:
$ gcc base.c -o base 'pkg-config --cflags --libs gtk+-2.0'
gcc: pkg-config --cflags --libs gtk+-2.0: No such file or directory
base.c:1:21: error: gtk/gtk.h: No such file or directory

There are other compile errors which follow, all of which should be attributable to the fact that the compiler can't find gtk.h, so I won't repeat them here.

gtk+-2.0.pc is in the directory /usr/local/libdata/pkgconfig, so I created and exported the environment variable PKG_CONFIG_PATH, as described in the man page for pkg-config:

Code:
$ PKG_CONFIG_PATH=/usr/local/libdata/pkgconfig
$ export PKG
$ echo $PKG_CONFIG_PATH
/usr/local/libdata/pkgconfig

I know that pkg-config is seeing gtk+-2.0.pc, because running the command on its own produces (what appears to be) the desired output:

Code:
$pkg-config --cflags --libs gtk+-2.0
-D_THREAD_SAFE -I/usr/local/include/gtk-2.0 -I/usr/local/lib/gtk-2.0/include -I/
usr/local/include/atk-1.0 -I/usr/local/include/cairo -I/usr/local/include/pango-
1.0 -I/usr/local/include -I/usr/local/include/glib-2.0 -I/usr/local/lib/glib-2.0
/include -I/usr/local/include/pixman-1 -I/usr/local/include/freetype2 -pthread 
-L/usr/local/lib -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgdk_pixbuf-2.0 -lpangoc
airo-1.0 -lgio-2.0 -lXext -lXrender -lXinerama -lXi -lXrandr -lXcursor -lXcompos
ite -lXdamage -lpangoft2-1.0 -lXfixes -lcairo -lX11 -lpango-1.0 -lm -lfreetype -
lfontconfig -lgobject-2.0 -lgmodule-2.0 -lglib-2.0

So I can't figure out why gcc isn't processing the pkg-config argument correctly. Can anyone help?
 
Wow. Can't believe I spent so much time trying to figure it out and didn't realize that. Thank you so much! Problem solved.
 
Back
Top