RE: Callbacks when glade file is loaded using a dynamic library




Hi Tristan,

 

As per my second post, I have been compiling my .so dynamic library and "myapp" with the --export-dynamic 
flag.

 

I have however, solved the problem. The solution was to replace the dlopen() and other related functions with 
the correspondening functions in the g_module family.

 

Cheers for your help :)
 
Date: Fri, 23 Apr 2010 11:04:38 -0400
Subject: Re: Callbacks when glade file is loaded using a dynamic library
From: tvb gnome org
To: abxccd msn com; gtk-app-devel-list gnome org

On Fri, Apr 23, 2010 at 4:40 AM, dfg dfg <abxccd msn com> wrote:
Hi Tristan,

I am not sure if the symbols need to be visible in "myapp". Currently, myapp
attaches a glade file to create its interface and uses dlopen to open the
.so dynamic library. The .so library loads its own GTK Builder which loads a
second glade file and attaches it to a container in myapp's glade file.

Your app has callbacks that need to be looked up by GtkBuilder.

Your plugin has also callbacks that need to be looked up by GtkBuilder

The fact you have a plugin and an app is completely besides the point.

You need to expose the symbols in your *_app_* so that GtkBuider can
read those symbols from the global namespace... of your app... to load
callbacks in your glade file that can only be found in your *app*, which
needs to be compiled with --export-dynamic ... did you try that yet before
writing back to the list please ?

Thanks,
-Tristan



At present state, the callbacks in the .so library are not being found by
the GTK Builder loaded by the dynamic library.
However, callbacks contained in "myapp" works perfectly with the glade file
loaded by myapp.

I am quite new at this, so can you please explain what you mean by "export
the symbols of my app"?

Cheers :)

Date: Thu, 22 Apr 2010 22:08:44 -0400
Subject: Re: Callbacks when glade file is loaded using a dynamic library
From: tvb gnome org
To: abxccd msn com
CC: gtk-app-devel-list gnome org

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 <abxccd 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: tvb gnome org
To: abxccd msn com
CC: gtk-app-devel-list gnome org

On Thu, Apr 22, 2010 at 7:21 PM, dfg dfg <abxccd 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.

________________________________
Hotmail & Messenger. Get them on your phone now.
                                          
_________________________________________________________________
Live connected. Get Hotmail & Messenger on your phone.
http://go.microsoft.com/?linkid=9724462


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