View on GitHub

DSFML

Introduction

This tutorial outlines some of the easiest/fastest ways to get the source built. This does not outline every possible way.

Make sure you have:

This tutorial assumes that git, cmake, and your compilers of choice are installed and you can use them from your terminal of choice

The DSFML project actually comes in two parts. DSFMLC is a library that wraps SFML in a C calling convention, and DSFML wraps the calls to the C code in D for more idiomatic usage. In order to use DSFML you will need both.

Building DSFMLC

As DSFML needs DSFMLC to work, we'll build that first. DSFMLC uses CMake in order to configure and generate make files. For a more in depth look on using CMake with DSFMLC, you can look at SFML's CMake tutorial as they are nearly identical in the way they are set up.

Note: The following builds the 2.1 version specifically. If you want to build git HEAD, just use git clone https://github.com/Jebbs/DSFMLC.git

Windows

On Windows you can use either VC or MinGW as your compiler. You can also use VC to generate 64 bit libraries. DSFMLC also includes implib for easy building of libraries to be used with DMD. Also be aware that since you most likely do not need it when using D, DSFMLC statically links the C++ standard library into the the compiled .dll's. If you do not want this, add -DSFML_USE_STATIC_STD_LIBS=FALSE to your cmake command.

Here are what I assume will be the three most common set ups:

VC with implib(for usage with DMD):

git clone -b 2.1 --depth 1 https://github.com/Jebbs/DSFMLC.git
cd DSFMLC
cmake -G"NMake Makefiles" .
nmake
implib

VC 64bit

git clone -b 2.1 --depth 1 https://github.com/Jebbs/DSFMLC.git
cd DSFMLC
cmake -G"NMake Makefiles" .
nmake

MingW 32bit with implib

git clone -b 2.1 --depth 1 https://github.com/Jebbs/DSFMLC.git
cd DSFMLC
cmake -G"MinGW Makefiles" .
mingw32-make
implib

Linux and OS X

Linux and OS X are much easier since we don't really have to worry about different compilers.

git clone -b 2.1 --depth 1 https://github.com/Jebbs/DSFMLC.git
cd DSFMLC
cmake .
make
sudo make install

That is it! You now have shared libraries/dlls ready to go.

Building DSFML

If you do not use dub, DSFML comes with a build script that makes it simple to build static libraries for dmd, gdc, and ldc. It is smart enough to run correctly based on the system and compiler you use, but in order to use it correctly, your compiler of choice needs to be on PATH.

For example, if you want to build on 32 bit Linux with gdc:

git clone -b v2.1.0 --depth 1 https://github.com/Jebbs/DSFML.git
cd DSFML
gdc build.d -obuild
./build

This will correctly build 32 bit static libraries for gdc.

You can also use rdmd if you have it. For example:

git clone -b v2.1.0 --depth 1 https://github.com/Jebbs/DSFML.git
cd DSFML
rdmd build

will build static libraries for what ever system you happen to be running for use with DMD.

For more information about what the script can do, pass it -help.