If you have symbols that need to be visible in 'myapp', they need to be
exported to in order to by found by a g_module_lookup(); did you also
export the symbols of you app ?

Cheers,
        -Tristan

On Thu, Apr 22, 2010 at 9:53 PM, dfg dfg <abx...@msn.com> wrote:
> Thank you Tristan.
>
> I actually tried the --export-dynamic flag before posting, but could not get
> it to work. I feel that it is most likely a problem in my makefile.am (I am
> using automake and libtool to generate the makefiles).
>
> Here is the make file for the compilation of the dynamic library:
>
> libmyplugin= /
> libmyplugin_LTLIBRARIES=libmyplugin.la
> libmyplugin_la_SOURCES=libmyplugin.c libmyplugincallbacks.c
> include_HEADERS = libmyplugincallbacks.h
> libmyplugin_la_LDFLAGS= -lc -lgcc -avoid-version @PACKAGE_LDFLAGS@
> libmyplugin_la_LIBDADD = --export-dynamic @PACKAGE_LIBS@
> INCLUDES = @PACKAGE_CFLAGS@
>
> Here is my configure.ac
>
> AC_PREREQ(2.59)
> AC_INIT(myapp, 1.0)
> PKG_CHECK_MODULES(GTK, gtk+-2.0 gmodule-2.0 gmodule-export-2.0)
> PACKAGE_CFLAGS="-g -Wall $GTK_CFLAGS"
> PACKAGE_LIBS="-g $GTK_LIBS -ltar"
> PACKAGE_LDFLAGS="-Wl, --export-dynamic $GTK_LDFLAGS"
> AC_SUBST(PACKAGE_CFLAGS)
> AC_SUBST(PACKAGE_LIBS)
> AC_SUBST(PACKAGE_LDFLAGS)
> AM_PROG_LIBTOOL
> AC_CANONICAL_SYSTEM
> AM_INIT_AUTOMAKE()
> AC_PROG_CC
> AC_CONFIG_FILES(Makefile src/Makefile src/modules/Makefile
> src/modules/libmyplugin/Makefile)
> AC_OUTPUT
>
> For some reason though, callbacks in "myapp" the main app that loads in the
> .so files work fine. Any ideas appreciated. :)
>
>
>
>> Date: Thu, 22 Apr 2010 21:37:48 -0400
>> Subject: Re: Callbacks when glade file is loaded using a dynamic library
>> From: t...@gnome.org
>> To: abx...@msn.com
>> CC: gtk-app-devel-list@gnome.org
>>
>> On Thu, Apr 22, 2010 at 7:21 PM, dfg dfg <abx...@msn.com> wrote:
>> >
>> > Hi everyone,
>> >
>> > Currently, I have built my main application using glade. This file is
>> > then loaded by a C application.
>> >
>> > I then created another interface using Glade. When my main application
>> > loads, it loads a .so library which contains code for this subsection (kind
>> > of like a plugin).
>> >
>> > The .so file loads in the second glade file and attaches it into the
>> > interface of the main application. This all works problem.
>> >
>> > The problem I am facing now is that gtk_builder_connect_signals
>> > (builder, NULL); does not work.
>> >
>> > For my .so file, i have 3 files:
>> >
>> >   -libmyplugin.c
>> >   -libmyplugincallbacks.h
>> >   -libmyplugincallbacks.c
>> >
>> >
>> > My code for the libmyplugin.c file looks like this:
>> >
>> >   #include <stdlib.h>
>> >   #include <gtk/gtk.h>
>> >   #include "libmyplugincallbacks.h"
>> >
>> >   #define GUI "libmyplugingui.ui"
>> >   int startplugin(){
>> >      extern *mainBuilder;
>> >      GtkBuilder *subbuilder;
>> >
>> >      //Do things like attach the glade file into the main glade file.
>> >      gtk_builder_connect_signals (builder, NULL);
>> >
>> >   }
>> >
>> >
>> >
>> > My libmyplugincallbacks.h
>> >
>> >   #include <gtk/gtk.h>
>> >
>> >   void myfunc (GtkCellRenderer *cell, GtkCellEditable *editable, const
>> > gchar *path, gpointer data);
>> >
>> >
>> >
>> > My libplugincallbacks.c
>> >
>> >   #ifdef HAVE_CONFIG_H
>> >   #  include <config.h>
>> >   #endif
>> >
>> >   #include "libmyplugincallbacks.h"
>> >   #include <string.h>
>> >
>> >   void myfunc(GtkCellRenderer *cell, GtkCellEditable *editable, const
>> > gchar *path, gpointer data){
>> >     if (GTK_IS_ENTRY (editable))
>> >       {
>> >       //Do stuff
>> >       }
>> >   }
>> >
>> >
>> >
>> > When I compile my program, the .so file compiles properly. However, when
>> > ever I run the program, it loads the .so file. Once GTK builder gets to the
>> > stage where it connects the signals, it will complain that "myfunc" cannot
>> > be found. I have double checked the name of the function in my glade file
>> > and it is spelt and entered correctly.
>>
>> You generally need to export your symbols by linking the app with
>> --export-dynamic flag:
>>
>> pkg-config --libs gmodule-2.0
>>
>> Should do the right thing to make your symbols visible.
>>
>> Cheers,
>> -Tristan
>
> ________________________________
> Hotmail & Messenger. Get them on your phone now.
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Reply via email to