Use bindbc-sdl statically

russhy russhy at gmail.com
Sat Apr 24 17:20:06 UTC 2021


On Saturday, 24 April 2021 at 16:48:49 UTC, Ishax wrote:
> It's using the same D code as with the dynamic setup which I 
> was able to produce a window with.
> Yet the .exe functions if I supply it with .dlls. Thats silly.

you didn't read my message


Remove all the code used to loadSDL, it's not needed anymore with 
static compilation




```
dependency "bindbc-sdl" version="~>0.1.0"
versions "BindSDL_Static"
subConfigurations "bindbc-sdl" "staticBC"
sourceFiles "my_sdl2.lib" "my_sdl2image.lib"
``


```D
import bindbc.sdl;
import core.stdc.stdio;

int main() {
   SDL_Window* window = null;
   SDL_Surface* screenSurface = null;
   if (SDL_Init(SDL_INIT_VIDEO) < 0) {
     printf("could not initialize sdl2: %s\n", SDL_GetError());
     return 1;
   }
   window = SDL_CreateWindow(
			    "hello_sdl2",
			    SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
			    SCREEN_WIDTH, SCREEN_HEIGHT,
			    SDL_WINDOW_SHOWN
			    );
   if (window == null) {
     printf("could not create window: %s\n", SDL_GetError());
     return 1;
   }
   screenSurface = SDL_GetWindowSurface(window);
   SDL_FillRect(screenSurface, null, 
SDL_MapRGB(screenSurface.format, 0xFF, 0xFF, 0xFF));
   SDL_UpdateWindowSurface(window);
   SDL_Delay(2000);
   SDL_DestroyWindow(window);
   SDL_Quit();
   return 0;
}
```

This should work


More information about the Digitalmars-d-learn mailing list