www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - GtkD

reply Russel Winder <russel winder.org.uk> writes:
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

I have built and installed GtkD from master/HEAD of a clone of the Git
repository. At least I hope it is successful!

A simple hello world in a label application is the trial. Sadly I get
pages and pages of linker errors. Is there a canonical command line to
build a single file applications that someone can tell me so I can try
it.

Thanks.

--=20
Russel.
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D
Dr Russel Winder      t: +44 20 7585 2200   voip: sip:russel.winder ekiga.n=
et
41 Buckmaster Road    m: +44 7770 465 077   xmpp: russel winder.org.uk
London SW11 1EN, UK   w: www.russel.org.uk  skype: russel_winder
Aug 10 2013
next sibling parent "Kagamin" <spam here.lot> writes:
Applications using a third-party library are not single-file 
applications: they need that library too.
Aug 10 2013
prev sibling next sibling parent reply Mike Wey <mike-wey example.com> writes:
On 08/10/2013 05:46 PM, Russel Winder wrote:
 I have built and installed GtkD from master/HEAD of a clone of the Git
 repository. At least I hope it is successful!

 A simple hello world in a label application is the trial. Sadly I get
 pages and pages of linker errors. Is there a canonical command line to
 build a single file applications that someone can tell me so I can try
 it.

 Thanks.

The linker probably can't find the GtkD library. 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 On Windows you will need to list gtkd.lib on the commandline with it's relative or absolute path. -- Mike Wey
Aug 10 2013
parent Mike Wey <mike-wey example.com> writes:
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(Obje tG.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
Aug 11 2013
prev sibling next sibling parent Russel Winder <russel winder.org.uk> writes:
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

On Sat, 2013-08-10 at 23:01 +0200, Mike Wey wrote:
[=E2=80=A6]
 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=20
 could use pkg-config:
=20
 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: =20 helloWorld_d_gtkd.o:(.data+0xb0): undefined reference to `_D3gtk10M= ainWindow12__ModuleInfoZ' helloWorld_d_gtkd.o:(.data+0xb8): undefined reference to `_D3gtk5La= bel12__ModuleInfoZ' helloWorld_d_gtkd.o:(.data+0xc0): undefined reference to `_D3gtk4Ma= in12__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? Will gdc be able to cope with: PKG_CONFIG_PATH=3D$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. 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.
 On Windows you will need to list gtkd.lib on the commandline with it's=

 relative or absolute path.

What's Windows? ;-) --=20 Russel. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D Dr Russel Winder t: +44 20 7585 2200 voip: sip:russel.winder ekiga.n= et 41 Buckmaster Road m: +44 7770 465 077 xmpp: russel winder.org.uk London SW11 1EN, UK w: www.russel.org.uk skype: russel_winder
Aug 11 2013
prev sibling parent Russel Winder <russel winder.org.uk> writes:
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

Mike,

Thanks for picking up on this and helping out. Much appreciated.

On Sun, 2013-08-11 at 15:26 +0200, Mike Wey wrote:
[=E2=80=A6]
 Unfortunately that doesn't make it obvious. Could you check the exact=20
 name of the ModuleInfo in the library?
=20
 nm --defined-only libgtkd-2.a | grep ModuleInfo | grep gobject | grep gtk=

I took a different tack and so these investigations are no longer possible. Sorry. [=E2=80=A6]
 When the GtkD library is compiled with gdc the .pc file will contain the=

 appropriate flags for gdc.

Sponditious. But it does mean they need to be stored in a place that is GDC compiler specific. [=E2=80=A6]
 The different compilers aren't binary compatible so you will need to use=

 the same compiler to build the lib and the application.

OK, I took this as impetus to delete the old installation as being unsound and start again. I built a LDC (ldc2) version and put the install in an LDC specific location so I can also do GDC and DMD installs. This version worked entirely fine. Thus the problem must have been an incomplete or improper build originally. Sorry for the noise. However it has been helpful as I know know more about GtkD :-) Sadly, QtD would be more generally useful since Qt is easier to install on OS X and Windows than Gtk and I need to be cross-platform.=20
 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=20
 compiler adds to the command yourself.

Now I just need to amend the SCons D tool to take all the source code in at once rather than generate individual .o files=E2=80=A6 --=20 Russel. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D Dr Russel Winder t: +44 20 7585 2200 voip: sip:russel.winder ekiga.n= et 41 Buckmaster Road m: +44 7770 465 077 xmpp: russel winder.org.uk London SW11 1EN, UK w: www.russel.org.uk skype: russel_winder
Aug 12 2013