Reputation: 197
I'm trying to use sdl2, but when I try to run my program it gives me an error that says
code execution can't proceed because SDL2.dll couldn't be found. try reinstalling [...]
I'm compiling from the terminal, without any IDEs (I'm writing code in Sublime Text). My command looks like this
g++ src\main.cpp -o ..\..\test.exe -L lib\sdl32\lib -l SDL2 -I lib\sdl32\inc -m32
and my file system like this
I tried putting the .exe
file in the same directory as the lib
files, but it doesn't work.
I thought the problem might be that it's looking for SDL2.dll
files and all of them are libSDL2.*
and I tried changing the file names but it didn't work.
I also thought the problem was the extension, because they are all in *.dll.a
, *.a
or *.la
, I tried changing that and it didn't work (I also tried a combination of the two).
This is my main.cpp
#define SDL_MAIN_HANDLED
#include <SDL.h>
int main(int argc, char* argv[]) {
SDL_Init(SDL_INIT_EVERYTHING);
SDL_Window* window = SDL_CreateWindow("Window", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 800, 450, SDL_WINDOW_SHOWN);
SDL_Renderer* renderer = SDL_CreateRenderer(window, -1, 0);
SDL_SetRenderDrawColor(renderer, 0, 0, 255, 255);
SDL_RenderClear(renderer);
SDL_RenderPresent(renderer);
SDL_Delay(3000);
SDL_Quit();
return 0;
}
Am I missing a file or a compiler flag or something?
Upvotes: 1
Views: 2140
Reputation: 39638
libSDL2.dll.a
is an import library. You use it at compile-time to link the code to load the .dll
into your binary. You will still need to have the SDL2.dll
file at runtime which contains the actual implementation. On Windows, .dll
files are searched in the PATH
; the simplest way to use them is to put them in the directory that contains the executable.
The .dll
file is available for download on the SDL website, you seem to only have the development files.
Upvotes: 3