我在編譯D程序時遇到問題,該程序使用SDL使用從DOS調用的生成文件,其中SDL應由「廢棄」包裝。另外,如果我在測試程序中使用一個編譯指示進行鏈接,它會告訴我lib文件有錯誤43,而不是有效的庫文件。D在Windows上與Derelict2綁定的SDL
如何使它鏈接,並我使用錯誤的堆棧(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
dmd不能使用VC lib文件。它需要由dmc創建的OMF,或者用類似objconv的東西進行轉換。 – Trass3r
objconv不覺得能夠處理導入庫 – Adder
但coffimplib.exe似乎做了一些事情。 – Adder