Reputation: 341
Hello I recently download Derelict2 by checking out the Derelict2 branch here and I try a little program with SDL :
import derelict.sdl.sdl;
int main()
{
bool run = true;
SDL_Init(SDL_INIT_VIDEO);
SDL_SetVideoMode(400, 300, 32, SDL_HWSURFACE | SDL_RESIZABLE | SDL_DOUBLEBUF);
SDL_Event event;
while(run)
{
SDL_WaitEvent(&event);
switch(event.type)
{
case SDL_QUIT:
run = false;
}
}
return 0;
}
I compile with this command line :
ldc2 -I=/usr/include/d/Derectlict2/DerelictSDL -I=/usr/include/d/Derectlict2/DerelictUtil -of=../bin/test -release -run main.d
but there is this error :
../bin/test.o: In function `_Dmain':
main:(.text+0x40): undefined reference to `_D8derelict3sdl8sdlfuncs8SDL_InitPUkZi'
main:(.text+0x69): undefined reference to `_D8derelict3sdl8sdlfuncs16SDL_SetVideoModePUiiikZPS8derelict3sdl8sdltypes11SDL_Surface'
main:(.text+0xa2): undefined reference to `_D8derelict3sdl8sdlfuncs13SDL_WaitEventPUPS8derelict3sdl8sdltypes9SDL_EventZi'
../bin/test.o:(.rodata+0x2c): undefined reference to `_D8derelict3sdl3sdl8__ModuleZ'
collect2: ld returned 1 exit status
Error: linking failed:
status: 1
I'm a really beginner in D and in programming in general, and I don't understand what's are the object file.
So if anyone understand what I did wrong please tell me
Upvotes: 1
Views: 2910
Reputation: 6287
Just use rdmd like that, second line.
Strange thing is though, that it complains about _D8derelict3sdl8sdlfuncs8SDL_InitPUkZi
.
Looks like an extern(C) is missing.
Upvotes: 1
Reputation: 54270
You need to link with Derelict2's libraries.
Below the imports, add:
pragma(lib, "relevant-libraries");
For example:
pragma(lib, "/usr/include/d/Derelict2/lib/libDerelictGL.a");
pragma(lib, "/usr/include/d/Derelict2/lib/libDerelictGLU.a");
pragma(lib, "/usr/include/d/Derelict2/lib/libDerelictSDL.a");
pragma(lib, "/usr/include/d/Derelict2/lib/libDerelictUtil.a");
If you are on Windows then those library files will be .lib
s
Alternatively, you can add the files to your build command by adding these flags:
-L/usr/inlcude/d/Derelict2/lib/libDerelictSDL.a -L/usr/ ... etc.
By the looks of things, you should only need to reference the SDL library.
Upvotes: 1