Link SDL samples under cygwin with GDC

pedro alves pedro.alves at
Sun Jul 2 04:01:42 PDT 2006

Fauvel Wilfried wrote:
> Hi all,
> I am trying to build SDL samples under cygwin with GDC compiler,
> I 'm using SDL and opengl found on (both
> copied in the root directory of my project in /SDL and /opengl),
> and I try to use the following Makefile :
> CC = gdc
> INCLUDES = -ISDL -Iopengl
> LDFLAGS_GL=  -lopengl32 -lglu32
> LIBRARIES = -L. -L/sw/lib  -LSDL -Lopengl
> all:
>      $(CC) testgl.d -c $(INCLUDES)
>      $(CC) testgl.o $(LIBRARIES) $(LDFLAGS_GL) $(LDFLAGS_SDL)  -o test.exe
>      $(CC) testbitmap.d -c $(INCLUDES)
>      $(CC) testbitmap.o $(LIBRARIES) $(LDFLAGS_GL) $(LDFLAGS_SDL)  -o
> testbitmap.exe
>      $(CC) picture.d -c $(INCLUDES)
>      $(CC) picture.o $(LIBRARIES) $(LDFLAGS_GL) $(LDFLAGS_SDL)  -o
> picture.exe
> If I don't add opengl32.dll in the same directory of opengl32.lib, testgl.o
> couldn't be linked (It seems opengl like is missing), and it crash during
> SDL initialisation when I try to run.

Up until very recent cvs versions, ld wouldn't consider the $(name).lib
form of libraries/import libs. When you put the dll in the search path, 
it would find it and link directly into it instead.
In many cases, it is recommended to link into the dll directly for 
efficiency reasons, but there are some cases where it is impossible.

Check it out here:

In those cases you can simply rename ex:
opengl.lib -> libopengl.a.

Pedro Alves

More information about the D.gnu mailing list