Hi all, I've got a problem with DMD linker on Windows.
I've got one file written in C and one in D, both are attached. I build a working executable on Linux without any problems using: $ gcc `sdl-config --cflags` -c -o sdl.o sdl.c $ dmd -c stuff.d $ dmd sdl.o stuff.o -L-lSDL -L-lpthread -ofp1 I tried to build it on Windows. I downloaded dmd.2.035.zip, dmc.zip and an SDL development package for Windows. The code was compiled without problems: $ dmc sdl.c -c -I path/to/SDL/include -I /mingw/include $ dmd -c stuff.d stuff.obj and sdl.obj were created. Adding "-I /mingw/include" was necessary because without it compilation failed due to lack of "strings.h" header file. $ dmd sdl.obj stuff.obj path/to/SDL.lib -ofp1.exe The linker returned 0 but p1.exe was not built. A file called p1.map was created though. I also tried the following command: $ link stuff+sdl,p1.exe,,path/to/SDL.lib but the results were similar. What might be a reason of this bug? Are you aware of such problems? Best regards, -- Jan Stępień
#include <stdlib.h> #include "SDL.h" #define SCREEN_WIDTH (640) #define SCREEN_HEIGHT (480) SDL_Surface *screen; /* * From http://www.libsdl.org/intro.en/usingvideo.html */ void putpixel(unsigned x, unsigned y, Uint8 R, Uint8 G, Uint8 B) { Uint32 color = SDL_MapRGB(screen->format, R, G, B); if ( SDL_MUSTLOCK(screen) ) { if ( SDL_LockSurface(screen) < 0 ) { return; } } switch (screen->format->BytesPerPixel) { case 1: { /* Assuming 8-bpp */ Uint8 *bufp; bufp = (Uint8 *)screen->pixels + y*screen->pitch + x; *bufp = color; } break; case 2: { /* Probably 15-bpp or 16-bpp */ Uint16 *bufp; bufp = (Uint16 *)screen->pixels + y*screen->pitch/2 + x; *bufp = color; } break; case 3: { /* Slow 24-bpp mode, usually not used */ Uint8 *bufp; bufp = (Uint8 *)screen->pixels + y*screen->pitch + x; *(bufp+screen->format->Rshift/8) = R; *(bufp+screen->format->Gshift/8) = G; *(bufp+screen->format->Bshift/8) = B; } break; case 4: { /* Probably 32-bpp */ Uint32 *bufp; bufp = (Uint32 *)screen->pixels + y*screen->pitch/4 + x; *bufp = color; } break; } if ( SDL_MUSTLOCK(screen) ) { SDL_UnlockSurface(screen); } SDL_UpdateRect(screen, x, y, 1, 1); } int init_video(char doublebuf, char fullscreen) { Uint32 flags = 0; if (doublebuf) flags |= doublebuf; if (fullscreen) flags |= SDL_FULLSCREEN; if (SDL_Init(SDL_INIT_VIDEO) != 0) { fprintf(stderr, "Unable to initialize SDL: %s\n", SDL_GetError()); return 0; } atexit(SDL_Quit); screen = SDL_SetVideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, 16, flags); if (screen == NULL) { fprintf(stderr, "Unable to set video mode: %s\n", SDL_GetError()); return 0; } SDL_WM_SetCaption("Window Title", "Icon Title"); return 1; }
stuff.d
Description: Binary data
