Compiling my 1st GTK+ program



OK, I have a very simple program that goes as follows:
------------ base.c ---------------------
#include <gtk/gtk.h>

int main( int   argc, char *argv[] ){
    GtkWidget *window;
    gtk_init (&argc, &argv);
    window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
    gtk_widget_show  (window);
    gtk_main ();
    return 0;
}
-------------- eof -----------------------



With the help of Todd and the litle bit I could find about writing Makefiles I wrote the following script to 
compile the above program:
----------- Makefile  ----------
# Compiler name
CC=gcc

# Flagas
CFLAGS = -Wall -g -ansi `pkg-config --cflags --libs gtk+-2.0`
LDLIBS = `pkg-config --libs gtk+-2.0`

# Variables
OBJS = base.o  
EXEC = Base

#Application name
all: $(OBJS)
    $(CC) $(LDLIBS) $(OBJS) -o $(EXEC)

# Thanks tod :)
$(EXEC): $(OBJS)

base.o: 
    $(CC) $(CFLAGS) -c base.c

clean:
    rm -f $(OBJS)
    rm -f $(EXEC)

PHONY: clean
--------- eof -------------

The program compiles and creates a 'base.o' file, but I get the following error:

base.o(.text+0x44): In function `main':
/home/Jamil/dev/jme/tmp/GTK_TST/base.c:7: undefined reference to `_gtk_init_abi_check'
base.o(.text+0x50):/home/Jamil/dev/jme/tmp/GTK_TST/base.c:9: undefined reference to `_gtk_window_new'
base.o(.text+0x5e):/home/Jamil/dev/jme/tmp/GTK_TST/base.c:10: undefined reference to `_gtk_widget_show'
base.o(.text+0x63):/home/Jamil/dev/jme/tmp/GTK_TST/base.c:12: undefined reference to `_gtk_main'
collect2: ld returned 1 exit status
make: *** [all] Error 1


I am not an expert, but it looks like the linker is having problems finding the gtk+ libraries, am I right? 
It is irrelevant if I am right or not; I would not know how to fix problem anyway!
Any help would be very much appreciated.

Thanks Todd for the help with the Makefile, I really don't know much about Makefiles, but little by little 
all this stuff is falling into place

-- 
FYI
http://www.astro.umd.edu/~marshall/abbrev.html

E-Mail Policy
http://www.vif.com/users/escalante/Email_Policy.html

* You cannot exercise your power to a 
  point of humiliation.
               - Jean Chretien

* The media's the most powerful entity on earth. They have the power to make the innocent guilty and to make 
the guilty innocent, and that's power.
                 - Malcom X
You experience miracles everyday, the first one today happened when you first opened your eyes!
     --- Jorge Escalante


__________________________________________________________________
Switch to Netscape Internet Service.
As low as $9.95 a month -- Sign up today at http://isp.netscape.com/register

Netscape. Just the Net You Need.

New! Netscape Toolbar for Internet Explorer
Search from anywhere on the Web and block those annoying pop-ups.
Download now at http://channels.netscape.com/ns/search/install.jsp



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