我在使用从 DOS 调用的 makefile 编译使用 SDL 的 D 程序时遇到问题,其中 SDL 应该由 Derelict 包装。此外,如果我在测试程序中使用编译指示进行链接,它会告诉我 lib 文件有错误 43,不是有效的库文件。
如何使其链接,我是否使用了错误的堆栈(Visual C/C++)?我认为不是因为它正在寻找 lib 文件。
测试程序
//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
}
生成文件
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
生成文件输出
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