# Using SDL with D

I’m trying to get a sample SDL app written in D to build. Right now it
just has an empty main() function and import SDL;. Whenever I try to
build with gdc, like this:

gdc -I"path\to\sdl.d\files" main.d -lmingw32 -lSDL -lmwindows

I get this error:

undefined reference to _D3SDL12__ModuleInfoZ’

I’m using the SDL module files from here:
http://int19h.tamb.ru/files.html and the latest 1.2.11 MinGW version of
the SDL libraries, which I figured would be enough to get my simple
bare-bones app to build. Adding -lSDLmain doesn’t help either, and I’m
not sure it belongs since this is D.

Anyone ever built an SDL app using D and gdc? Any ideas what’s wrong?

This isn’t an SDL issue. It’s a D problem. Specifically, the modules from
DedicateD are way, way out of date. D has evolved quite a bit since they
were written. I recommend that you use the DerelictSDL bindings from
http://www.dsource.org/projects/derelict/. Further, you may find issues with
some D libraries when using GDC. It tends to lag a version or two behind DMD
releases and some libraries are targeted at DMD specifically.

DerelictSDL will work with GDC, but the build script doesn’t currently
support it out of the box. I suggest that you use a build tool like Bud (
http://www.dsource.org/projects/build/) or Rebuild (
http://www.dsource.org/projects/dsss/wiki/Rebuild) with all of your D
projects. Both tools can parse the imports you use in your app, compile
them, and link the object files in automatically. This means you can build
an entire project by passing one source file to the build tool, rather than
feeding it every module you need, and also do not need precompile any
libraries you might use. So you could, for example, bypass the Derelict
build script and not build the DerelictSDL library to use it (the
recommended approach). Bud has some issues when building with GDC. Rebuild
was created to address those issues and is much more configurable. I highly
recommend it. Bud and Rebuild have become the de facto standards for
building D applications, so you really ought to know how to use them as many
projects require them.

Anyway, if you get any further errors like this please take them to the
dititalmars.d.learn newsgroup rather then the SDL mailing list. They have
nothing to do with SDL.On 2/18/07, Brad wrote:

I’m trying to get a sample SDL app written in D to build. Right now it
just has an empty main() function and import SDL;. Whenever I try to
build with gdc, like this:

gdc -I"path\to\sdl.d\files" main.d -lmingw32 -lSDL -lmwindows

I get this error:

undefined reference to _D3SDL12__ModuleInfoZ’

I’m using the SDL module files from here:
http://int19h.tamb.ru/files.html and the latest 1.2.11 MinGW version of
the SDL libraries, which I figured would be enough to get my simple
bare-bones app to build. Adding -lSDLmain doesn’t help either, and I’m
not sure it belongs since this is D.

Anyone ever built an SDL app using D and gdc? Any ideas what’s wrong?

SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org