GTK+ Forums Forum Index GTK+ Forums
Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Can't compile

 
Post new topic   Reply to topic    GTK+ Forums Forum Index -> GTK+ Programming
Author Message
Alanius
Familiar Face


Joined: 14 Mar 2006
Posts: 5

PostPosted: Tue Mar 14, 2006 7:21 pm    Post subject: Can't compile Reply with quote

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
Back to top
Micah Carrick
Never Seen the Sunlight


Joined: 21 Sep 2005
Posts: 481
Location: Portland, OR USA

PostPosted: Tue Mar 14, 2006 10:19 pm    Post subject: Reply with quote

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
Back to top
Alanius
Familiar Face


Joined: 14 Mar 2006
Posts: 5

PostPosted: Wed Mar 15, 2006 8:03 pm    Post subject: Reply with quote

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.
Back to top
Micah Carrick
Never Seen the Sunlight


Joined: 21 Sep 2005
Posts: 481
Location: Portland, OR USA

PostPosted: Wed Mar 15, 2006 8:42 pm    Post subject: Reply with quote

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?
Back to top
Alanius
Familiar Face


Joined: 14 Mar 2006
Posts: 5

PostPosted: Sat Mar 18, 2006 9:52 am    Post subject: Reply with quote

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: (Plaintext)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/* 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 */
Back to top
Micah Carrick
Never Seen the Sunlight


Joined: 21 Sep 2005
Posts: 481
Location: Portland, OR USA

PostPosted: Sat Mar 18, 2006 6:03 pm    Post subject: Reply with quote

It compiles for me just fine using this:

Code: (Plaintext)
1
 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
Back to top
Alanius
Familiar Face


Joined: 14 Mar 2006
Posts: 5

PostPosted: Sat Mar 18, 2006 9:53 pm    Post subject: Reply with quote

Code: (Plaintext)
1
2
3
4
5
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$
Back to top
Micah Carrick
Never Seen the Sunlight


Joined: 21 Sep 2005
Posts: 481
Location: Portland, OR USA

PostPosted: Sun Mar 19, 2006 12:05 am    Post subject: Reply with quote

Try renaming your file from main.cc (C++) to just main.c since '__gxx_personality_v0' is a symbol from libstdc++
Back to top
Alanius
Familiar Face


Joined: 14 Mar 2006
Posts: 5

PostPosted: Sun Mar 19, 2006 12:23 pm    Post subject: Reply with quote

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?
Back to top
Micah Carrick
Never Seen the Sunlight


Joined: 21 Sep 2005
Posts: 481
Location: Portland, OR USA

PostPosted: Sun Mar 19, 2006 5:37 pm    Post subject: Reply with quote

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.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    GTK+ Forums Forum Index -> GTK+ Programming All times are GMT
Page 1 of 1

 


Powered by phpBB © 2001, 2005 phpBB Group
CodeBB 1.0 Beta 2
Protected by Anti-Spam ACP