[tutorial] msys2, sdl2, ffmpeg, and codelite
This is a tutorial for setting up a native Windows GCC environment with the CodeLite IDE.
-
Go to msys2.org and follow the instructions there to install msys2. (after installing, be sure to run msys2.exe and run pacman -Syu commands, as instructed)
-
Go to codelite.org and download and run the installer.
-
Launch msys2.exe and run the following commands,
-
pacman -S mingw64/mingw-w64-x86_64-gcc
-
pacman -S mingw64/mingw-w64-x86_64-SDL2
-
pacman -S mingw64/mingw-w64-x86_64-ffmpeg
-
pacman -S mingw64/mingw-w64-x86_64-make
-
Add C:\msys64\mingw64\bin to your Windows environment path. Plenty of online guides on how to do this if you get stuck.
-
Launch CodeLite.exe
-
Run the setup wizard to configure the build settings. Scan your computer and it should detect your MinGW compiler.
-
Your build settings should match those in image below. You will need to manually add mkdir.exe
-
Create a workspace and a new project. Simple console gcc app will do fine.
-
In workspace panel, right click your new project folder and go to Settings.
-
For SDL2 to work properly, you need to add Include Paths and Preprocessors under the Compiler tab.
-
For Linker tab,
-
Time to test the whole thing. In your project /src/main.c, replace the text with the following,
#include <stdio.h>
#include <SDL2/SDL.h>
#include <libavutil/imgutils.h>
#include <libavutil/samplefmt.h>
#include <libavutil/timestamp.h>
#include <libavformat/avformat.h>
#include <libswresample/swresample.h>
int main(int argc, char *argv[]){
SDL_Init(SDL_INIT_VIDEO);
SDL_Quit();
return 0;
}
-
Go to Build tab, click Build Project. Hopefully the console doesn’t give you compilation errors.
-
Rejoice!