Skip to content

Instantly share code, notes, and snippets.

@dmoa
Last active January 12, 2022 00:15
Show Gist options
  • Save dmoa/d4c76881bce8a846f152626717a2b4e2 to your computer and use it in GitHub Desktop.
Save dmoa/d4c76881bce8a846f152626717a2b4e2 to your computer and use it in GitHub Desktop.
Setup SDL project without Visual Studio or CMake (Windows)
1. Download Compiler
2. Add Compiler to Path
3. Download SDL
4. Use SDL
$. Extras
1. Download compiler:
https://sourceforge.net/projects/mingw-w64/files/
2. Add bin folder path into enviroment variables
Path should be something like:
C:\Program Files\mingw-w64\x86_64-7.3.0-posix-seh-rt_v5-rev0\mingw64\bin
How to add environment variables:
https://stackoverflow.com/questions/44272416/how-to-add-a-folder-to-path-environment-variable-in-windows-10-with-screensho#44272417
3. Download SDL
https://www.libsdl.org/download-2.0.php
-> Development Libraries -> Windows -> SDL2-devel-2.020-mingw.tar.gz (MinGW 32/64-bit)
If you cannot extract .tar.gz use https://cloudconvert.com/gz-to-zip
4. Use SDL
Copy paste SDL2.dll from bin into project folder
Rename x86_64-w64-mingw32 to 64 (more convenient)
Add this to your compile command (manually or to build script):
-I"...\SDL\64\include" -L"...\SDL\64\lib" -lmingw32 -lSDL2main -lSDL2 -lws2_32 -Wl,-subsystem,windows
Example of full command (gcc for c, g++ for c++):
gcc.exe main.c -I"C:\dev\SDL\64\include" -L"C:\dev\SDL\64\lib" -Wl,-subsystem,windows -lmingw32 -lSDL2main -lSDL2 -lws2_32 -o main.exe
$. Extras
a) SDL_image
https://www.libsdl.org/projects/SDL_image/
-> Development Libraries -> Windows -> SDL2_image_devel-2.0.5-mingw.tar.gz (MinGW 32/64 bit)
Copy SDL_image.h to SDL\64\include
Copy all dlls to project folder
b) SDL_ttf
https://github.com/libsdl-org/SDL_ttf/releases
-> SDL2_ttf-devel-2.0.18-mingw-tar.gz
Copy SDL_ttf.h to SDL\64\include
Copy all dlls to project folder
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment