Re: Updated to Ubuntu 11.04 and Can't Compile



On Sat, 5 Mar 2011, Craig Bakalian wrote:

So are the libraries actually there?

ls -al /usr/lib/libgtk-x11-2.0*

There should be a symlink, something like

/usr/lib/libgtk-x11-2.0.so -> libgtk-x11-2.0.so.0.2000.1

This is what I get.  It looks okay to me.

ls -al /usr/lib/libgtk-x11-2.0*
-rw-r--r-- 1 root root 6606378 2011-02-23 01:24 /usr/lib/libgtk-x11-2.0.a
-rw-r--r-- 1 root root     988 2011-02-23 01:24 /usr/lib/libgtk-x11-2.0.la
lrwxrwxrwx 1 root root      26 2011-03-05 06:23 /usr/lib/libgtk-x11-2.0.so -> libgtk-x11-2.0.so.0.2400.1
lrwxrwxrwx 1 root root      26 2011-03-05 06:23 /usr/lib/libgtk-x11-2.0.so.0 -> libgtk-x11-2.0.so.0.2400.1
-rw-r--r-- 1 root root 4023088 2011-02-23 01:24 /usr/lib/libgtk-x11-2.0.so.0.2400.1

Yep, looks OK. So now it's time to reconsider your scatter-gun
approach to use of pkg-config. Correct compilation of a
single-source C program looks like this:

$(CC) $(CFLAGS) -o $(TARGET) $(SOURCE) $(LIBS)

The $(LIBS) directive should trail the rest of the command, so
that the linker knows what's required from the libraries. So set
yourself up a proper Makefile. Here's a rough pattern, supposing
you want to compile a GTK-based executable named "foo" from C
source "foo.c":

CC = gcc -g -O2 -Wall # or to taste
CFLAGS = `pkg-config --cflags gtk+-2.0`
LIBS = `pkg-config --libs gtk+-2.0`

foo: foo.c
        $(CC) $(CFLAGS) -o @$ $< $(LIBS)

Allin Cottrell



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]