www.digitalmars.com         C & C++   DMDScript  

D.gnu - Link SDL samples under cygwin with GDC

reply "Fauvel Wilfried" <wilfried.fauvel laposte.net> writes:
Hi all,

I am trying to build SDL samples under cygwin with GDC compiler,
I 'm using SDL and opengl found on http://shinh.skr.jp/d/porting.html (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
LDFLAGS_SDL= -lSDL -lSDL_d

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.

testbitmap.d and picture.d doesn't like at all :

gdc
testbitmap.o -L. -L/sw/lib  -LSDL -Lopengl -lopengl32 -lglu32 -lSDL -lSDL_d
-o testbitmap.exe
testbitmap.o:testbitmap.d:(.text+0x67c): undefined reference to
`__D7picture12picture_bitsAh'
collect2: ld returned 1 exit status
make: *** [all] Error 1

gdc
icture.o -L. -L/sw/lib  -LSDL -Lopengl -lopengl32 -lglu32 -lSDL -lSDL_d  -o
picture.exe
/usr/lib/gcc/i686-pc-cygwin/3.4.4/../../../libgphobos.a(cmain.o):cmain.d:(.t
ext+0x1a): undefined reference to `__Dmain'
collect2: ld returned 1 exit status
make: *** [all] Error 1

Is there any way to solve my linking problems ?

Thanks for your answers.
Jul 01 2006
parent pedro alves <pedro.alves domatica.pt> writes:
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 http://shinh.skr.jp/d/porting.html (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
 LDFLAGS_SDL= -lSDL -lSDL_d
 
 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: http://sourceware.org/ml/binutils/2006-06/msg00280.html In those cases you can simply rename ex: opengl.lib -> libopengl.a. Cheers, Pedro Alves
Jul 02 2006