Reputation: 5868
I have problems compiling a D program that uses SDL using a makefile called from DOS, where SDL is supposed to be wrapped by Derelict. In addition, if I use a pragma inside the test program for linking, it tells me the lib file has error 43, not a valid library file.
How to make it link, and am I using the wrong stack (Visual C/C++) ? I think not because it is looking for lib files.
test program
//pragma(lib, "D:\\Development\\SDL-1.2.15\\lib\\x86\\SDL.lib");
import derelict.sdl.sdl;
void main()
{
DerelictSDL.load();
// now you can call SDL functions
}
makefile
DMD = dmd
WINDRES = windres.exe
LDFLAGS = -O2 -s `sdl-config --libs`
DFLAGS =
RM = rm -f
#OBJS = main.o graphic.o grid.o node.o appicon.opc
SRCS = toh_fractal.d
# graphic.d grid.d node.d appicon.opc
PROG = toh_fractal
DERELICT = D:\\Development\\Derelict2
INCLUDE_DERELICT = $(DERELICT)\\import
LIB_DERELICT = DerelictSDL
LIB_SDL = SDL
#$(DERELICT)\\lib\\
VERS = 0.1.1
.PHONY: clean distclean
all: $(PROG)
$(PROG): $(SRCS)
$(DMD) $(DFLAGS) $(PROG) -I$(INCLUDE_DERELICT) appicon.res -L$(LIB_DERELICT) -L$(LIB_SDL)
appicon.res: appicon.rc sierpinski.ico
windres -i appicon.rc -o appicon.res
distclean:
$(RM) *~ $(OBJS) appicon.opc stdout.txt stderr.txt
clean:
$(RM) *~ $(OBJS) $(PROG) appicon.opc stdout.txt stderr.txt
makefile output
C:\D\D_fractals_of_hanoi>make all
dmd toh_fractal -ID:\\Development\\Derelict2\\import appicon.res -LDerelictSDL -LSDL
OPTLINK (R) for Win32 Release 8.00.12
Copyright (C) Digital Mars 1989-2010 All rights reserved.
http://www.digitalmars.com/ctg/optlink.html
OPTLINK : Warning 9: Unknown Option : NOIDERELICTSDLSDL
toh_fractal.obj(toh_fractal)
Error 42: Symbol Undefined _D8derelict3sdl3sdl12__ModuleInfoZ
toh_fractal.obj(toh_fractal)
Error 42: Symbol Undefined _D8derelict3sdl3sdl11DerelictSDLC8derelict3sdl3sdl17DerelictSDLLoader
--- errorlevel 2
Upvotes: 0
Views: 345
Reputation: 2002
Derelict uses the C dl
lib (dlopen
, dlclose
, dlsym
) to dynamically load the shared library, so you have to use dynamic libraries.
Upvotes: 0
Reputation: 919
Derelict is meant ot be used with dynamic linking. You should put the right .so or .dll in your application directory and Derelict will find it.
Upvotes: 1