-
Notifications
You must be signed in to change notification settings - Fork 3
How to setup SDL2 with Code::Blocks on Windows
Amine B. Hassouna edited this page Sep 14, 2021
·
2 revisions
The easiest way to setup Code::Blocks is to use the setup executable with MinGW (C/C++ compiler).
Follow this tutorial: Installing Code::Blocks
- Download the development library from www.libsdl.org.
- Use WinRAR to extract the compressed file. Right-click on the downloaded file and click on
Extract file...
.
- In the "Destination path" text field, set
C:\
as shown below, then click onOK
.
- Go to the
C:\
disk folder and verify that the SDL2 library was extracted successfully (as show below).
- Open Code::Blocks.
- Click on
New
button (has a paper with a plus sign as icon). - Click on
Project...
as shown below.
- In the opened window, scroll down and select
SDL2 project
, then click onGo
.
- The following window shows a welcome message, so it is better to tick the
Skip this page next time
, then click onNext
.
- Now you should give a title to your project (It is a good practice to don't use
spaces
)
Do not forget to select a folder to put your project in. Do that by clicking on the...
button.
Then just click onNext
.
- At this step, you should select the location of the SDL2 library.
Click on...
button.
Go to the C:\<The library folder>\x86_64-w64-mingw32
as shown below.
In our case: C:\SDL2-2.0.16\x86_64-w64-mingw32
Then click on Next
.
- Click on
Finish
to create your project.
- In the project tree (left panel), double-click on
main.cpp
to open it.
- Remove all the content of the default
main.cpp
file. (UseCtrl + a
to select all) - Go to sdl2-pointerless and copy all the content to your
main.cpp
file. (UseCtrl + a
to select all)
- Finally, build and run your project.
Take a look on the SDL2 pointerless project.
It is one-file C SDL2 project. It is meant for beginners to let them create SDL-based projects without any pointer specific knowledge. It offers a micro-library that help create any grid-based user interface.
The only dependency of this project is the SDL2 library.
See SDL/SDL2 samples and projects
Author: Amine B. Hassouna @aminosbh
This tutorial is distributed under the terms of the MIT license