Search code examples
darchlinuxgtkd

getting started with gtkd


I'm new to D, and want to experiment with gtkd. I'm on arch linux, and installed the dmd2-complete (dmd 2.0.56) and gtkd-svn (gtkd built against D2) packages. I also verified that D itself was working properly (compiled and ran a basic writefln("hello world"); program).

Now I'm trying to get gtkd up and running, and am having a very hard time compiling and linking the basic helloworld program from the examples.

import gtk.MainWindow;
import gtk.Label;
import gtk.Main;

void main(string[] args)
{
  Main.init(args);
  MainWindow win = new MainWindow("Hello World");
  win.setDefaultSize(200, 100);
  win.add(new Label("Hello World"));
  win.showAll();

  Main.run();
}

Specifically, what options do I need to pass to dmd to get this to link? Pretty much all the documentation I can find skips over this entirely.

The gtkd-svn package has installed the following in /usr/lib:

 /usr/lib/libgtkd.a
 /usr/lib/libgtkdgl.a
 /usr/lib/libgtkdsv.a

Solution

  • Okay, so I found the answer in the "related questions" sidebar. Leaving this up here since google didn't bring up the other thread when I was searching, and it might have better luck with this one. You need to pass in the linker options as -L-l, specifically in this case

    dmd -L-lgtkd -L-ldl hellogtk.d
    

    and everything works nicely.