[Glade-users] signal handler problem



On Wed, 2007-02-14 at 17:59 +0100, salaria113 at yahoo.com wrote:
Thanks for your answer , I try to compile under Linux with the
following commands:

g++ -c -DXTHREADS -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include
-I/usr/X11R6/include -I/usr/include/atk-1.0 -I/usr/include/pango-1.0
-I/usr/include/freetype2 -I/usr/include/glib-2.0
-I/usr/lib/glib-2.0/include -I/usr/include/libglade-2.0 main.cpp

Aha.  You're using a C++ compiler.  C++ mangles symbol names to support
its nifty features such as function overloading.  libglade doesn't deal
well with this.  Therefore, functions which are to be Glade signal
handlers must be declared to use C linkage (with 'extern "C"'), like so:

extern "C" void
openButtonListener( GtkButton *openButton,
                   gpointer   data )
{
    g_print ("Hello World\n");
}

This will disable symbol mangling for this function, so the
'openButtonListener' function is exposed as-is and libglade can find it.
You still need all the export-dynamic jazz, of course.

- Michael

-- 
Michael Ekstrand
Research Assistant, Scalable Computing Laboratory
Goanna, compute cluster and InfiniBand network monitor tool:
        http://www.scl.ameslab.gov/Projects/Monitor/





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