Computer Graphics and Multimedia System Lab
MSYS2 + SDL3 + graphics.h for Windows Environment Setup

1. Why This Setup?

Modern compilers (64-bit) are incompatible with Turbo C (16-bit DOS-based). As a result, old graphics programs cannot run or compile. We must either use outdated tools or upgrade to a modern development environment.


Why we use modern tools instead of Turbo C

  • Better performance
  • Future-ready development
  • No system downgrade required
Mindset: Do not go backward. Always upgrade your system.
2. Required Tools (Overview)

MSYS2 → Linux-like development environment for Windows

MSYS2 UCRT64 → Terminal where all commands are executed

SDL3 → Graphics rendering engine

SDL3_bgi → Enables graphics.h support

graphics.h → Used in C graphics programs

GCC / Clang → Compilers

SDL3_bgi.dll → Required runtime file for execution

Important: Always use MSYS2 UCRT64 shell.
3. Setup Steps (Run Once Only)
✔ This section is ONLY for installation/setup
✔ After this, you never repeat these steps

Step 3.0: Download & Install MSYS2

From official MSYS2 website.

Step 3.1: Open MSYS2 UCRT64 Shell

Search in Windows:

MSYS2 UCRT64

Step 3.2: Update system

pacman -Syu
pacmanMSYS2 package manager
-SyuUpdate system + packages

Step 3.3: Install SDL3

pacman -S make mingw-w64-ucrt-x86_64-sdl3

Step 3.4: Install Clang

pacman -S mingw-w64-ucrt-x86_64-clang

Step 3.5: Download SDL3_bgi (ZIP)

From official website. Extract it anywhere (Desktop / Downloads)

Important Note:
If you see /your-folder/ → replace it with your actual extracted path.
Example: /c/Users/YourName/Downloads/SDL3_bgi

Step 3.6: Copy files

cp /your-folder/graphics.h /ucrt64/include/
cp /your-folder/SDL3_bgi.h /ucrt64/include/SDL3/
cp /your-folder/SDL3_bgi.dll /ucrt64/bin/
cpCopy command
/ucrt64/includeHeader files location
/ucrt64/binDLL runtime location

Step 3.7: Go to SDL3_bgi folder

cd /your-folder/SDL3_bgi
cdChange directory (move into folder)

Step 3.8: Compile library

clang -c SDL3_bgi.c -o SDL3_bgi.o
clangCompiler
-cCompile only (no exe)
.cSource file
.oObject file

Step 3.9: Create library

ar rcs libSDL3_bgi.a SDL3_bgi.o
arArchive tool
rcsCreate static library

Step 3.10: Copy library

cp libSDL3_bgi.a /ucrt64/lib/
4. Compile & Run (Run Each Time)
✔ Compile & Run = Every time you write code
✔ Setup = Only once

Step 4.0: Go to project folder

cd /e/PersonalFolder/lab01
cdChange directory (move into folder)
/e/...Your drive path in MSYS2

Step 4.1: Compile program

gcc main.c -o line.exe -lSDL3_bgi -lSDL3 -lm
gccCompiler
main.cSource code file
-o line.exeOutput executable name
-lSDL3_bgiGraphics library
-lSDL3SDL3 engine
-lmMath library

Step 4.2: Run program

./line.exe
Rule: You compile every time after changing code, then run.
5. Common Errors
  • graphics.h not found → Wrong copy path
  • SDL3 not found → Missing installation
  • undefined reference → Library not linked
6. Checklist
  • ✔ MSYS2 installed
  • ✔ SDL3 installed
  • ✔ Clang installed
  • ✔ Files copied correctly
  • ✔ Library built
  • ✔ Program runs