[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Dynamic library loading with lgi
- From: Rena <hyperhacker@...>
- Date: Mon, 19 Nov 2012 10:36:05 -0500
On Mon, Nov 19, 2012 at 7:11 AM, Pavel Holejsovsky
> On 11/19/12 4:59 AM, Rena wrote:
>> I've run into an issue when porting a program from LuaGnome to lgi.
>> This program loads another C library which uses some GDK functions.
>> Since it's a shared library I guess it expects the host program to
>> load the appropriate GDK libraries as well, and LuaGnome would do
>> this, but lgi does not? So the library can't be loaded:
>> lua5.1: error loading module 'display' from file
>> ./display/build/display.so: undefined symbol: gdk_draw_rgb_image
>> I feel like I fixed this problem once before, by referencing some GDK
>> function in the Lua script before loading the library that depends on
>> it, so that the GDK libraries would be loaded. But I can't find the
>> program that did that now (maybe I dreamed it?), and the result is
>> even stranger than I expected - lgi.Gdk.draw_rgb_image is nil. As is
>> lgi.Gdk.pixbuf_new, on the off chance that one function had been
>> changed. So I'm not sure how you're meant to even use GDK with lgi,
>> let alone load the library so that others can use it?
> This is expected, because gdk_draw_rgb_image() is part of GDK2, but left out
> of GDK3 - all rendering was switched to cairo-only in gtk3. So assuming
> that you have both GDK2 and GDK3 (together with typelibs) installed, you can
> force using GTK2 (and GDK2 too) explicitly by
> local Gtk = lgi.require('Gtk', '2.0')
> local Gdk = lgi.Gdk
> Note that once you explicitely ask for Gtk-2.0, it is not needed to repeat
> the version request for Gdk-2.0, because Gdk-2.0 is already loaded as a
> dependency of Gtk-2.0
> That said, although writing apps targeted to gtk2 is certainly possible, I'd
> recommend to move to gtk3 if possible at all, because it is actively
> maintained (and this is true for both gtk upstream and lgi gtk overrides).
> Note that it is not possible to mix gtk2 and gtk3 in one process, so you
> must really decide whether change/recompile another library for gtk3 or
> target your application to gtk2.
Aha, I thought the library wouldn't compile at all in that case, but I
guess it compiles OK because GTK2 is still available, but then fails
to load with GTK3... makes sense. I'll see how to go about porting it.
Thanks for the help.
Sent from my Game Boy.