Discussion:
[Gwyddion-users] Installing a module on Gwyddion (using Mac)
Michele Della Ciana
2016-04-24 17:02:49 UTC
Permalink
Hi!

My name is Michele and I'm an Italian physics student.

I'm trying to install the minimal module in the totorial's section but when I start gwyddion it says:


(gwyddion:6946): GLib-GObject-WARNING **: cannot register existing type 'gchar'

**

GLib-GObject:ERROR:gvaluetypes.c:455:_g_value_types_init: assertion failed: (type == G_TYPE_CHAR)

Abort trap: 6

logout


and it closes.


To copile the module as a shared library I used:

gcc -fPIC -shared -o module.so main.cpp `pkg-config --cflags --libs gwyddion`

where main.cpp is the source code of the minimal module.


It compiles fine... the problem occurs when I put the "module.so" file in the module's directory.

By now I'm using gwyddion just as a library, but I hope to solve the problem!

I think is useful to know that I'm using a mac with OS X Yosemite and I have installed gwyddion using homebrew!


Sorry for my English, I hope the problem is clear!

Thanks in advance

Michele
David Nečas (Yeti)
2016-04-24 19:14:01 UTC
Permalink
On Sun, Apr 24, 2016 at 05:02:49PM +0000, Michele Della Ciana wrote:
> I'm trying to install the minimal module in the totorial's section but
> when I start gwyddion it says:
>
> (gwyddion:6946): GLib-GObject-WARNING **: cannot register existing type 'gchar'
>
> **
> GLib-GObject:ERROR:gvaluetypes.c:455:_g_value_types_init: assertion failed: (type == G_TYPE_CHAR)

This means some GLib initialisation is done twice. But since this is
not happening in Linux there is some difference in linking and library
loading – and as I do not understand the fine points of the OS X linker
I do not know where exactly.

> To copile the module as a shared library I used:
>
> gcc -fPIC -shared -o module.so main.cpp `pkg-config --cflags --libs gwyddion`
>
> where main.cpp is the source code of the minimal module.

I would try removing --libs. This, i.e. with libraries resolved through
the main program, is how we normally link all built-in modules in Unix.
It ensures not only library consistency but also faster startup.

The second thing to check would be renaming the file to .c, i.e. trying
to compile it as C instead of C++. It should not make a difference but
it is better to be sure.

The third thing would be trying the sample standalone module

http://gwyddion.net/apps/#sample-module

because it is linked using libtool that should know the right magic
linker flags for the corresponding operating system. While your command
works for me I do not know if it does the right thing in OS X.

BTW, I found a bug in the example. It will print

GwyApp-WARNING: Invalid function name my_invert_value.

The logging support was not tested... Replace

gwy_app_channel_log_add(data, id, id, "my_invert_value", NULL);

with

gwy_app_channel_log_add_proc(data, id, id);

to get rid of the warning.

Regards,

Yeti
Michele Della Ciana
2016-04-24 20:22:22 UTC
Permalink
I tried every method you suggested and at the end the first was the right one! I compiled using this line:
gcc -fPIC -shared -o module.so main.c `pkg-config --cflags gwyddion` -L/usr/local/Cellar/gwyddion/2.43/lib -L/usr/local/Cellar/gtkglext/1.2.0_1/lib -L/usr/local/Cellar/gtk+/2.24.29/lib -L/opt/local/lib -lgwyapp2 -lgwymodule2 -lgwyprocess2 -lglib-2.0

Linking just this 4 library!
Thank you very much!
You solve my problem! :)
________________________________________
Da: David Nečas (Yeti) <***@gwyddion.net>
Inviato: domenica 24 aprile 2016 19.14
A: Gwyddion use discussion
Oggetto: Re: [Gwyddion-users] Installing a module on Gwyddion (using Mac)

On Sun, Apr 24, 2016 at 05:02:49PM +0000, Michele Della Ciana wrote:
> I'm trying to install the minimal module in the totorial's section but
> when I start gwyddion it says:
>
> (gwyddion:6946): GLib-GObject-WARNING **: cannot register existing type 'gchar'
>
> **
> GLib-GObject:ERROR:gvaluetypes.c:455:_g_value_types_init: assertion failed: (type == G_TYPE_CHAR)

This means some GLib initialisation is done twice. But since this is
not happening in Linux there is some difference in linking and library
loading – and as I do not understand the fine points of the OS X linker
I do not know where exactly.

> To copile the module as a shared library I used:
>
> gcc -fPIC -shared -o module.so main.cpp `pkg-config --cflags --libs gwyddion`
>
> where main.cpp is the source code of the minimal module.

I would try removing --libs. This, i.e. with libraries resolved through
the main program, is how we normally link all built-in modules in Unix.
It ensures not only library consistency but also faster startup.

The second thing to check would be renaming the file to .c, i.e. trying
to compile it as C instead of C++. It should not make a difference but
it is better to be sure.

The third thing would be trying the sample standalone module

http://gwyddion.net/apps/#sample-module

because it is linked using libtool that should know the right magic
linker flags for the corresponding operating system. While your command
works for me I do not know if it does the right thing in OS X.

BTW, I found a bug in the example. It will print

GwyApp-WARNING: Invalid function name my_invert_value.

The logging support was not tested... Replace

gwy_app_channel_log_add(data, id, id, "my_invert_value", NULL);

with

gwy_app_channel_log_add_proc(data, id, id);

to get rid of the warning.

Regards,

Yeti

------------------------------------------------------------------------------
Find and fix application performance issues faster with Applications Manager
Applications Manager provides deep performance insights into multiple tiers of
your business applications. It resolves application problems quickly and
reduces your MTTR. Get your free trial!
https://ad.doubleclick.net/ddm/clk/302982198;130105516;z
_______________________________________________
Gwyddion-users mailing list
Gwyddion-***@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gwyddion-users
Loading...