GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Wed Jul 30, 2014 7:03 am

All times are UTC




Post new topic Reply to topic  [ 10 posts ] 
Author Message
 Post subject: Can't compile
PostPosted: Tue Mar 14, 2006 7:21 pm 
Offline
Familiar Face

Joined: Tue Mar 14, 2006 7:10 pm
Posts: 5
Hello.

I am absolutely new to the world of GTK.
I am using anjuta to compile a simple GTK window, but it just throws a load of error messages at me. Some of them have to do with glib, others with gtk.
Too bad I can't copy/paste from the window, but here are some of the more frequent ones:
glib:
gtypes.h:396: 'G_END_DECLS' does not name a type
garray.h:66: expected constructor, destructor, or type conversion before '*' token
gquark.h:38: GQuark does not name a type
gtk:
gdk-pixbuf-io.h:42: expected constructor, destructor, or type conversion before '*' token
gdk-pixbuf-loader.h:78: 'GError' has not been declared
gtkwidget.h:756: gchar has not been declared.
I have no idea what the problem is, and would be glad to recieve any help at all.

Thanks in advance,
Al

_________________
- Never argue with your compiler. Even if you're right, it won't budge. -


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 14, 2006 10:19 pm 
Offline
Never Seen the Sunlight

Joined: Wed Sep 21, 2005 12:07 am
Posts: 563
Location: Portland, OR USA
You're missing some libraries it seems to me, but I'm not entirely sure which ones. Do you know what "devel" libraries installed on your system? What distro are you using and how did you install gtk? When running the build from Anjuta, how did you setup Anjuta project and is it 1.2.x or 2.x version of Anjuta? Have you tried compiling manually with gcc? You're not running a 64 bit system are you?

- Micah

_________________
Micah Carrick - Forum Administrator
http://www.micahcarrick.com


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 15, 2006 8:03 pm 
Offline
Familiar Face

Joined: Tue Mar 14, 2006 7:10 pm
Posts: 5
I'm using Ubuntu Breezy, and I used synaptic to install the GTK development files.
My Anjuta is version 1.2.
Compiling manually gives me the same errors.
How do I find out how many bits my system uses?
Processor is Intel P4.

_________________
- Never argue with your compiler. Even if you're right, it won't budge. -


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 15, 2006 8:42 pm 
Offline
Never Seen the Sunlight

Joined: Wed Sep 21, 2005 12:07 am
Posts: 563
Location: Portland, OR USA
Don't worry about the bits... I had just seem a smiliar error for 64 bit linux... your does not apply. :)

Okay, first, it's importand that you have the "devel" packages (gtk-devel, libglade-devel, etc). I'm not familiar with Ubuntu or debian style packages, so I can't help you there (though I have the Ubuntu CDs coming in the mail).

As for the compillation errors, can you post your sample application code?

_________________
Micah Carrick - Forum Administrator
http://www.micahcarrick.com


Top
 Profile  
 
 Post subject:
PostPosted: Sat Mar 18, 2006 9:52 am 
Offline
Familiar Face

Joined: Tue Mar 14, 2006 7:10 pm
Posts: 5
As far as synaptic tells me, I have all the necessary libraries ...

Here's my code. I don't remember where I Crl-C/V'd it from.
Code:
/* example-start helloworld helloworld.c */

#include <gtk/gtk.h>

/* This is a callback function. The data arguments are ignored
* in this example. More on callbacks below. */
void hello( GtkWidget *widget,
            gpointer   data )
{
    g_print ("Hello World\n");
}

gint delete_event( GtkWidget *widget,
                   GdkEvent  *event,
                   gpointer   data )
{
    /* If you return FALSE in the "delete_event" signal handler,
     * GTK will emit the "destroy" signal. Returning TRUE means
     * you don't want the window to be destroyed.
     * This is useful for popping up 'are you sure you want to quit?'
     * type dialogs. */

    g_print ("delete event occurred\n");

    /* Change TRUE to FALSE and the main window will be destroyed with
     * a "delete_event". */

    return(TRUE);
}

/* Another callback */
void destroy( GtkWidget *widget,
              gpointer   data )
{
    gtk_main_quit();
}

int main( int   argc,
          char *argv[] )
{
    /* GtkWidget is the storage type for widgets */
    GtkWidget *window;
    GtkWidget *button;
   
    /* This is called in all GTK applications. Arguments are parsed
     * from the command line and are returned to the application. */
    gtk_init(&argc, &argv);
   
    /* create a new window */
    window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
   
    /* When the window is given the "delete_event" signal (this is given
     * by the window manager, usually by the "close" option, or on the
     * titlebar), we ask it to call the delete_event () function
     * as defined above. The data passed to the callback
     * function is NULL and is ignored in the callback function. */
    gtk_signal_connect (GTK_OBJECT (window), "delete_event",
                        GTK_SIGNAL_FUNC (delete_event), NULL);
   
    /* Here we connect the "destroy" event to a signal handler. 
     * This event occurs when we call gtk_widget_destroy() on the window,
     * or if we return FALSE in the "delete_event" callback. */
    gtk_signal_connect (GTK_OBJECT (window), "destroy",
                        GTK_SIGNAL_FUNC (destroy), NULL);
   
    /* Sets the border width of the window. */
    gtk_container_set_border_width (GTK_CONTAINER (window), 10);
   
    /* Creates a new button with the label "Hello World". */
    button = gtk_button_new_with_label ("Hello World");
   
    /* When the button receives the "clicked" signal, it will call the
     * function hello() passing it NULL as its argument.  The hello()
     * function is defined above. */
    gtk_signal_connect (GTK_OBJECT (button), "clicked",
                        GTK_SIGNAL_FUNC (hello), NULL);
   
    /* This will cause the window to be destroyed by calling
     * gtk_widget_destroy(window) when "clicked".  Again, the destroy
     * signal could come from here, or the window manager. */
    gtk_signal_connect_object (GTK_OBJECT (button), "clicked",
                               GTK_SIGNAL_FUNC (gtk_widget_destroy),
                               GTK_OBJECT (window));
   
    /* This packs the button into the window (a gtk container). */
    gtk_container_add (GTK_CONTAINER (window), button);
   
    /* The final step is to display this newly created widget. */
    gtk_widget_show (button);
   
    /* and the window */
    gtk_widget_show (window);
   
    /* All GTK applications must have a gtk_main(). Control ends here
     * and waits for an event to occur (like a key press or
     * mouse event). */
    gtk_main ();
   
    return(0);
}
/* example-end */

_________________
- Never argue with your compiler. Even if you're right, it won't budge. -


Top
 Profile  
 
 Post subject:
PostPosted: Sat Mar 18, 2006 6:03 pm 
Offline
Never Seen the Sunlight

Joined: Wed Sep 21, 2005 12:07 am
Posts: 563
Location: Portland, OR USA
It compiles for me just fine using this:

Code:
gcc -o hello -Wall -g main.c `pkg-config gtk+-2.0 --cflags --libs `


I'm not an expert, but it seems as though it's not finding certain library header files for glib. Try compiling with teh above command

_________________
Micah Carrick - Forum Administrator
http://www.micahcarrick.com


Top
 Profile  
 
 Post subject:
PostPosted: Sat Mar 18, 2006 9:53 pm 
Offline
Familiar Face

Joined: Tue Mar 14, 2006 7:10 pm
Posts: 5
Code:
al@Soloriens:~/Projects/wirc/src$ gcc -o hello -Wall -g main.cc `pkg-config gtk+-2.0 --cflags --libs `
/tmp/ccOIorZv.o:(.eh_frame+0x11): undefined reference to `__gxx_personality_v0'
collect2: ld returned 1 exit status
al@Soloriens:~/Projects/wirc/src$

_________________
- Never argue with your compiler. Even if you're right, it won't budge. -


Top
 Profile  
 
 Post subject:
PostPosted: Sun Mar 19, 2006 12:05 am 
Offline
Never Seen the Sunlight

Joined: Wed Sep 21, 2005 12:07 am
Posts: 563
Location: Portland, OR USA
Try renaming your file from main.cc (C++) to just main.c since '__gxx_personality_v0' is a symbol from libstdc++

_________________
Micah Carrick - Forum Administrator
http://www.micahcarrick.com


Top
 Profile  
 
 Post subject:
PostPosted: Sun Mar 19, 2006 12:23 pm 
Offline
Familiar Face

Joined: Tue Mar 14, 2006 7:10 pm
Posts: 5
All right! Thanks! It works.
That is odd.
So I was using a C compiler to compile a C/C++ project? Why didn't Anjuta discover that?

_________________
- Never argue with your compiler. Even if you're right, it won't budge. -


Top
 Profile  
 
 Post subject:
PostPosted: Sun Mar 19, 2006 5:37 pm 
Offline
Never Seen the Sunlight

Joined: Wed Sep 21, 2005 12:07 am
Posts: 563
Location: Portland, OR USA
I don't know why Anjuta or even gcc did that. It seems that it makes the determination based on the file extension. I did not know that.

_________________
Micah Carrick - Forum Administrator
http://www.micahcarrick.com


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 10 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group