![]() ![]() ![]() Wall enables many compiler warning messages, it is not required but it is recommended. I is for include and -L is for linking the library. Worth noting is that C17 was pretty much a bugfix version of C11, and the fixes are also applied to C11 in GCC - so the only difference from using -std=c11 is the value of _STDC_VERSION_. std=c17 means that the compiler uses the most recent C standard, ISO/IEC 9899:2018, known as both C17 and C18.īecause of this, the flag -std=c18 is equivalent. This will create a main.exe file in the project directory.Īs we can see everything works. Gcc -std=c17 main.c -I -Wall -lmingw32 -lSDL2main -lSDL2 -o main We then compile it with the following command: We are now ready to compile our main.c program, so open up cmd and go to the project directory. If it's not on this form, we have to define the macro SDL_MAIN_HANDLED before including the SDL.h header. Because of the way SDL works, the main method should be written as: The method on the left is the recommended way, and is what we will use. There are two ways to do this, as illustrated below. We will now make a very simple C program that initializes SDL, and then terminates. Now go into the SDL2/bin folder and copy the SDL2.dll file to where your main.c file is located (or main.cpp if you are writing in C ). exe file.įor the sake of this tutorial, we will rename this folder SDL2 and copy it into our project folder C:\Tutorial (which only has an empty main.c file). This folder contains the include- and library files needed for compiling, as well as the SDL2.dll file that we need to distribute along with the final compiled. ![]() Note that this is still the 64-bit version of the library. (this tutorial uses SDL2-devel-2.0.)Īfter extracting the contents using for example 7-Zip, copy the folder "x86_64-w64-mingw32", to where you want to store the library. ![]() Go to the SDL2 download page and download the latest development library for Windows using MinGW. Now we can make sure everything works correctly by opening cmd and typing in the gcc command. Open the start menu and search for "Edit the system environment variables" ->Ĭlick "Environment Variables" -> select "Path" under System variables and click "Edit" -> add mingw64\bin Step 1: Installing mingw-w64ĭownload mingw-w64, and during the install, make sure to install the 64-bit compiler x86_64, as shown below.Īfter the installer is done we need to add the mingw directory to PATH. Our example will be written in C using a 64-bit compiler but this works exactly the sameįor C and one could easily use a 32-bit compiler instead. This tutorial will go through the process of setting up the How to Setup SDL2 on Windows for C/C MATSSON.COM/PROG TOP BOTTOM How to Setup SDL2 on Windows for C/C ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |