Skip to content

Hello World Example on Ubuntu 19.10 (Linux)

Feldwor edited this page May 13, 2020 · 1 revision

Prerequisites

sudo snap install --classic dmd
sudo snap install dub

Create a new text file

touch "HelloWorld.d"

Edit the HelloWorld.d file and paste this Example inside

#!/usr/bin/env dub
/+ dub.sdl:
	name "hello"
	dependency "gtk-d" version="*"
+/
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();
}

Run the Example

dub HelloWorld.d

Source: https://forum.gtkd.org/groups/GtkD/thread/1122/