GtkD

Mike Wey mike-wey at example.com
Sun Aug 11 06:26:39 PDT 2013


On 08/11/2013 10:19 AM, Russel Winder wrote:
> On Sat, 2013-08-10 at 23:01 +0200, Mike Wey wrote:
> […]
>> The linker probably can't find the GtkD library.
>
> I have tried using dmd and ldc with a -L-L/path/to/library and gdc with
> -L/path/to/library but get subtly different error messages. Certainly
> all the unfound references are _D... ones so I assume they are D
> references.
>
>> On linux if you used "make install" to install the GtkD libraries you
>> could use pkg-config:
>>
>> dmd $(pkg-config --cflags --libs gtkd-2) MyApp.d
>
> Well putting the PGK_CONFIG_PATH in so as to find the .pc file, this
> give very large numbers of errors. The first three are:
>
>          helloWorld_d_gtkd.o:(.data+0xb0): undefined reference to `_D3gtk10MainWindow12__ModuleInfoZ'
>          helloWorld_d_gtkd.o:(.data+0xb8): undefined reference to `_D3gtk5Label12__ModuleInfoZ'
>          helloWorld_d_gtkd.o:(.data+0xc0): undefined reference to `_D3gtk4Main12__ModuleInfoZ'
>
> from then everything is internal to libgtkd-2.a not having references.
> This means though that it has found libgtkd-2.a so. An example:
>
> /home/users/russel/lib.Linux.x86_64/GtkD/lib//libgtkd-2.a(ObjectG.o):(.data+0xb0): undefined reference to `_D4gtkc7gobject12__ModuleInfoZ'
>
> All of them appear to be a lack of ModuleInfoZ as far as I can tell,
> which may make this an obvious problem?

Unfortunately that doesn't make it obvious. Could you check the exact 
name of the ModuleInfo in the library?

nm --defined-only libgtkd-2.a | grep ModuleInfo | grep gobject | grep gtkc

> Will gdc be able to cope with:
>
> PKG_CONFIG_PATH=$HOME/lib.Linux.x86_64/GtkD/share/pkgconfig pkg-config
> --cflags --libs gtkd-2
>
> -I/home/users/russel/lib.Linux.x86_64/GtkD/include/d/gtkd-2/
> -L-L/home/users/russel/lib.Linux.x86_64/GtkD/lib/ -L-lgtkd-2 -L-ldl
>
> These look appropriate to DMD and LDC but not GDC, and in a Linux
> context GDC is likely the compiler of choice.

When the GtkD library is compiled with gdc the .pc file will contain the 
appropriate flags for gdc.

> Is there an issue of you have to use the same compiler to link code to
> libraries as was used to build the libraries in the first place?  This
> is not the issue here as I get the same problem for all three compilers,
> some else is wrong possibly as well.


The different compilers aren't binary compatible so you will need to use 
the same compiler to build the lib and the application.

for linking its usually best to also use the compiler, using ld directly 
is an option but you'll then need to add the flags and libraries the 
compiler adds to the command yourself.

>> On Windows you will need to list gtkd.lib on the commandline with it's
>> relative or absolute path.
>
> What's Windows?  ;-)

:)

-- 
Mike Wey


More information about the Digitalmars-d mailing list