-
Notifications
You must be signed in to change notification settings - Fork 71
Manually setting up a GDC tool chain on Debian Testing
This how-to gives step-by-step instructions for setting up GtkD manually on a Debian Testing system. (As of this writing, July 24, 2013, the latest release is Debian Jessie, and the version of Gtk used is 3.8.2.) It should be applicable, servatis servandis, to all GNU/Linux and Unix-like systems.
The following packages should be installed.
- libgtk-3-dev (version 3.8.2-3)
- gdc-4.8 (version 4.8.1-2)
These packages should pull in the necessary dependencies. Of course, Make and other essential elements of a development tool chain should be installed.
- If necessary, create the folder where you want to install GtkD. For example, if you want it to be available system-wide, create
/opt/gtkd
; if you want it to be in your local user space, use/home/username/gtkd
. (This tutorial will assume/home/username/gtkd
throughout. Of course, the word "username" should be changed appropriately.) - The compiler is called
gdc-4.8
; I suggest creating a shortcut calledgdc
:
cd /home/username/gtkd
mkdir bin
cd bin
ln -s /usr/bin/gdc-4.8 gdc
Alternatively, you can modify the make file. See below.
- To set up an environment that works correctly, you will have to set some environment variables. I suggest making a script called
set_variables
with the following contents:
#!/bin/sh
CPPFLAGS="-I/home/username/gtkd/include"
LDFLAGS="-L/home/username/gtkd/lib"
PKG_CONFIG_PATH="/home/username/gtkd/share/pkgconfig"
LD_LIBRARY_PATH="/home/username/gtkd/lib"
PATH="/home/username/gtkd/bin:$PATH"
export CPPFLAGS LDFLAGS PKG_CONFIG_PATH LD_LIBRARY_PATH PATH
I usually place the script in the directory /home/username/gtkd
.
- You should invoke the script whenever you will use the tool chain, or else modify the appropriate profile scripts accordingly. To use the script, using the terminal window from which you will be doing the compilation, type
. /home/username/gtkd/set_variables
(For those not familiar with shell scripts, note that .
is short for source
, which permits one to execute all of the commands in a shell script without ever leaving the current environment. Otherwise, the script will be executed in a "child" environment that is destroyed once the script is finished—which is no good for setting environment variables. The space between .
and the file name is required.)
- Download the GtkD source code and unzip it in an appropriate directory (for example,
/home/username/gtkd/gtkd-220
):
mkdir /home/username/gtkd/gtkd-220
cd /home/username/gtkd/gtkd-220
unzip /home/username/Downloads/GtkD-2.2.0.zip
(Of course, /home/username/Downloads
represents whatever directory you downloaded the ZIP file to.)
-
Modify the make file (
GNUmakefile
in/home/username/gtkd/gtkd-220
) in a text editor. You will need to change the lineprefix=/usr/local
to reflect the installation directory. (For our purposes, change it toprefix=/home/username/gtkd
.) If necessary, modify the lineDC=gdc
toDC=gdc-4.8
. (This last step is not necessary if you made the symbolic linkgdc
above.) -
There appears to be a bug in one of the pkg-config files produced by GtkD 2.2.0. Search for the line
gtkd-$(MAJOR).pc:
. The next line that beginsecho Libs:
should be replaced with
echo Libs: $(LINKERFLAG)-lgtkd-$(MAJOR) $(LINKERFLAG)-L$(prefix)/lib/ $(LINKERFLAG)-ldl >> $@
(Alternatively, you can modify the file gtkd-2.pc
, which will be installed in /home/username/gtkd/shared/pkgconfig
, later on. See below.)
- Compile:
cd /home/username/gtkd/gtkd-220
make all
make install
If you are installing system-wide, the last command should instead be sudo make install
.
- Verify that the file
gtkd-2.pc
is correct. Open it in a text editor, and verify that theLibs:
section reads
Libs: -Xlinker -lgtkd-2 -Xlinker -L/home/username/gtkd/lib -Xlinker -ldl
If you did not modify the corresponding part of the make file, you will need to modify gtkd-2.pc
appropriately now.
- Try the program TestWindow:
cd /home/username/gtkd/gtkd-220
./TestWindow &
- Try compiling a demo program. For example:
cd /home/username/gtkd/gtkd-220/demos/cairo/cairoclock
gdc -02 -c main.d `pkg-config --cflags gtkd-2` -o main.o
gdc -02 -c clock.d `pkg-config --cflags gtkd-2` -o clock.o
gdc -o cairoclock clock.o main.o `pkg-config --libs gtkd-2`
./cairoclock &
(If you opened up a brand new terminal window, don't forget to do . /home/username/gtkd/set_variables
first. Of course, if you opted not to create a symbolic link to gdc-4.8
, use the latter instead.)