You are not logged in.

#1 2004-04-17 23:36:12

punkrockguy318
Member
From: New Jersey
Registered: 2004-02-15
Posts: 711
Website

Compiling GTK2 Programs

I've decided to take a look at GTK2, but when I tried compiling the example program, I get this error:

In function `main':
/home/punkrockguy318/gtk/main.cpp:7: undefined reference to `__gxx_personality_v0'
collect2: ld returned 1 exit status

My program is copied right from the site, because I got the same error when I wrote it myself.  Here is what I used to compile

g++ `pkg-config --cflags --libs gtk+-2.0` hello.cpp

What's the deal?

and just for fun, here's the program...

#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;
}

If I have the gift of prophecy and can fathom all mysteries and all knowledge, and if I have a faith that can move mountains, but have not love, I am nothing.   1 Corinthians 13:2

Offline

#2 2004-04-18 12:28:32

i3839
Member
Registered: 2004-02-04
Posts: 1,185

Re: Compiling GTK2 Programs

GTK is written in C, so I guess you need to have something like:

extern "C" {
#include <gtk/gtk.h>
}

Of course you can also just write your program in C instead of C++, or use the C++ GTK wrapper.

Offline

Board footer

Powered by FluxBB