How to use gtkD in Win7 and dmd (D2)?
Asked Answered
S

5

8

I downloaded gtkD-1.5.1 and extracted to some gtkD directory. What do I do next ? I don't understand if I have to compile and link it to some lib or just link to it in my code ?


Edit: (@dsimcha)

the command dsss build in gtkD main dir gave me this:

Could not detect versions.
Could not detect versions.
Could not detect versions.
Could not detect versions.
Could not detect versions.
undemofy

Could not detect versions.
Could not detect versions.
atk => DO-atk

cairo => DO-cairo

gdk => DO-gdk

gdkpixbuf => DO-gdkpixbuf

gio => DO-gio

glade => DO-glade

glib => DO-glib

gobject => DO-gobject

gthread => DO-gthread

gtk => DO-gtk

gtkc => DO-gtkc

pango => DO-pango

but no lib was created ?

Sardella answered 3/1, 2012 at 20:32 Comment(0)
E
1

Imanage to use GtkD without generating lib files, with rdmd.

  1. You must install Gtk+2 runtime
  2. Download GtkD source code to some dir
  3. Run rdmd --build-only -I/src

rdmd will autobuild GtkD and your project code alone, skipping the need to making libs and linking it manually.

Eisenhower answered 9/6, 2012 at 14:45 Comment(0)
G
2

I had problems using DSSS on Windows as well, you could try using Bud/Build.

Make sure that build.exe is in your path somewhere, then open a command line in your gtkD/src/build folder. Then run build gtkD.brf to create GtkD.lib.

Depending on your version of DMD, you'll get a lot of errors. Most of the ones I got was typedef being deprecated. Any file where that happened (it will tell you) I simply refactored typedef into alias, and it worked fine. The other error I got was with src/gtk/Toolbar.d, and an ambiguous virtual function getOrientation(). To fix this, go into src/gtk/OrientableIF.d and /src/gtk/ToolShellIF.d and comment out the getOrientation methods.

Using the most recent version of dmd (2.059), glib/DateTime.d won't compile. To make this file compile, simply comment out the method override hash_t toHash().

When you compile your project, use dmd <source files> -L <C:\Path\To\File>\GtkD.lib

Gastritis answered 16/2, 2012 at 20:34 Comment(0)
U
1

You need to compile gtkD into a binary. The standard way to do this is with DSSS. Basically, download and install DSSS, and then do a dsss build from the main gtkD directory.

Edit:

After you build gtkD using DSSS, you'll have a bunch of .lib files in the gtkD directory. You statically link these into your application. In addition, you need to have the GTK+ libraries installed in your Windows installation.

Unsociable answered 4/1, 2012 at 13:29 Comment(0)
B
1

Building the Library: I would recommend taking a look at the build guidelines for the project here are the steps that they layout to build the library:

  1. Get the latest stable version of DSSS and install it on your system.
  2. [OPTIONAL]. Update the dsss.conf file in the root of the project to suit your needs. Otherwise pay attention to the 'defaulttargets' key. If you want a standard gtkD build/installation, the defaults are fine.
  3. Build gtkD. Go to the root of the project (where this file is located) and run the following command:

    $ dsss build
    
  4. You may now install the libraries to your live filesystem. From the root of the project, run:

    $ dsss install **--prefix=/usr/local**
    

    Don't forget to set the prefix according to your needs. "/usr/local" is a sane default and should work on most systems without further action. If the chosen prefix is not on your PATH, don't forget to update your environment variables. Import files will also get automatically installed to the chosen prefix. Note: root access may be required to complete this step according to your system settings.

  5. Build your own programs using the provided dsss.conf files from any of the demo folders. Pay special attention to the buildflags used to build the demos. "-L-ldl" is necessary on Linux systems.
  6. Have fun!

Using the Library: After that you can then use the library in a few different ways in your own program depending on how your building it:

If you are using DSSS to build your own project then all you need to do is import the modules in code like this:

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();
}

Your dss.conf would look like this:

name = helloworld
[helloworld.d]
target = helloworld

And use the normal steps to build and install it:

$ dsss build
$ dsss install

Edit:: I just noticed that you want to use DMD directly, to compile your project you can use:

dmd helloworld.d -ofhelloworld -L+gtk.lib

Please note that this build style is not recommended for larger projects and you should use DSSS whenever practical.

Blowhard answered 16/2, 2012 at 21:8 Comment(0)
E
1

Imanage to use GtkD without generating lib files, with rdmd.

  1. You must install Gtk+2 runtime
  2. Download GtkD source code to some dir
  3. Run rdmd --build-only -I/src

rdmd will autobuild GtkD and your project code alone, skipping the need to making libs and linking it manually.

Eisenhower answered 9/6, 2012 at 14:45 Comment(0)
C
0

It seems that the latest release doesn't always work out of the box, you are better off with trunk HEAD by going to http://www.dsource.org/projects/gtkd/browser/trunk and clicking the Zip Archive link at the bottom, the version that worked for me was r952.

Download bud/build(version 3.04 worked fine) and call it like this build gtkD.brf

The error

Could not detect versions

is caused by not having dmd in path.

I tried gtkD 1.5.1 which is the current latest but then I got the typedef problem and after I fixed it manually I got the XOverlay problem and after a lot of searching I found that they are both fixed in SVN so I got trunk HEAD and it worked out of the box.

Clobber answered 1/6, 2012 at 11:30 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.