Re: gmodule help
- From: "Greg Steffensen" <greg steffensen gmail com>
- To: "Rick Jones" <rick jones2 hp com>
- Cc: gtk-list gnome org
- Subject: Re: gmodule help
- Date: Fri, 7 Apr 2006 17:59:14 -0400
Thanks- its actually quite simple. In case anyone else searches for info on this, on Linux, shared libraries usable with gmodule are compiled via
gcc -shared -fPIC -o libmylib.so libmylib.c `pkg-config --cflags --libs
glib-2.0`
The pkg-config arguments may need to be tweaked depending on your project, of course (if you're using, say, the G_MODULE_EXPORT macro inside your module, you'll need to add "gmodule-2.0" to your pkg-config args, for example... but that macro is only necessary for cross platform compatibility, its not needed if your code is intended only for Linux).
Greg
On 4/7/06, Rick Jones <rick jones2 hp com> wrote:
Greg Steffensen wrote:
> Hey, I'm trying to use gmodule, but am unfamiliar with libtool and
> linking, and am unsure about what compilation commands to use (I've gone
> through the libtool info pages, but still can't quite get it to work).
> Can anyone tell me how to compile a single source file that uses glib
> and gmodule into a ".so" file on Linux, such that gmodule can use it?
> I've pasted the source for the very simple test library and test
> executable I'm trying to get to work below, though I don't expect that
> their contents are important. Many thanks,
It is probably overkill, but you can take a gander at the
Makefile.am
Makefile.in configure and configure.ac in:
http://www.netperf.org/svn/netperf4/branches/glib_migration
for examples of what may not be pristine, nor adhere to chapter and
verse, but seem to be functional use of libtool with automake et al and
GModule.
>
> test.c (an executable that loads the library at runtime)
> ------------------------
> #include <glib.h>
> #include <gmodule.h>
>
> #define PLUGIN_FILE "./libtestplugin.so"
One thing I've just learned getting netperf4 to work on Linux, HP-UX,
AIX, MacOS X and Windows is that "g_module_open means never having to
include the suffix" so you can, and perhaps should (?) drop the ".so"
rick jones
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]