for everyone who got errors after makefile, you could: (1) use include, bin folders from folder x86_64-w64-mingw32 instead of the one selected in the video, because your computer identifies 64 bits version, not 32 bit version. (2) type comment "g++ -I src/include -L src/lib -o main main.cpp -lmingw32 -lSDL2main -lSDL2" directly into terminal instead of using makefile. (3) type comment "./main" in the terminal.
Sir, you are literally a blessing to humanity. You are like my guiding star, illuminating my path and filling my world with joy. Your presence brings a warmth that melts my heart and a smile that brightens my day. I'm grateful to have crossed paths with someone as captivating as you.
if the command "make" doesn't work for you, try typing "mingw32-make" instead. if you want to use it by typing "make", what I did was to duplicate the file "mingw32-make.exe" located in "C:\MinGW\bin" and rename it to "make.exe". it's probably not the cleanest but it is simple and it worked for me.
OMMMMMMMMMMMMMMMMMGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG THANK YOU SO MUCH I WAS TRYING TO FIGURE OUT WHY IT WASN'T WORKING FOR DAYS AND YOU JUST HELP SAVE MY LIFEEEEEEEEE THANK YOUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU :)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
You can change the name of that "mingw32-make.exe" file to "make.exe" and then you can just run the command "make" from the command line as long as you add it to the path correctly.
I had been struggling to get SDL2 to work in Eclipse for days, before I finally broke down and transitioned to Visual Studio Code. Your video was quick, clear, and informative; thank you!
Bro, I was waiting for you, Godsend man. There were always tutorials for Visual studio, or VSC that weren't that good. This one slaps, like the details, testing if it works and explaining along the way. Giving it a thumbs up!
Thank you very much from japan. I had difficulty in using SDL2 and searched for how to use it. Then, I found this video and I can solved this problem. I really appreeciate it.
If you are facing issues running building the Makefile then try the below steps: 1. Copy the i686-w64-mingw32/lib and /include folder into the src folder of your VSCODE project. Make sure you copy the lib and include folders manually instead of dragging and dropping it in VSCode. The folder structure is important i.e src/include and src/lib 2. Copy the i686-w64-mingw32/bin/SDL2.dll from the bin folder to your project folder. 3. For me, g++ was not working so I used gcc in the Makefile and finally got to work. Happy game development!
I've got an error just like this and can't find anything on stack overflow on how to address this. Is this tutorial out of date? Error: "SDL2/SDL.h: No such file or directory' @SonarSystemsCoUk
I had the same error. Worked out the solution was that I had made a couple of typos in the Makefile file. I had missed a '-' and also I had named my folder SRC not src, so needed to correct that.
If you're STILL getting errors even after using the 64 version of SDL2, then (1) replace your PATH variable for mingw/bin with the one for mingw64/bin. (2) Just add mingw64/bin to PATH variable without replacing the mingw/bin, and rename the g++ in mingw64/bin to something like g++64 and then change your command from (g++ main.cpp) to (g++64 main.cpp) This issue happened to me because I installed minGW first, then later installed minGW64
TO EVERYONE WHO GOT THE ERROR AFTER THE MAKE FILE if you are on windows 11 make sure you are using the 64 bit version of SDL as the 32 is not supported.. 32 bit version is selected in this tutorial
anything else that needs to be changed to make this work? I'm getting an error now when I try to use ./main, which when looked up everyone says its the wrong OS and that the json file needs to be edited. Any advice?
@@jozburn7503 hmm make sure you put the SDL.dll from the 64 bit folder as well. this worked for me, also make sure you delete the broken exe if it made one
@@em_raaa my compile line is "g++ -I src/include -L src/lib -o main main.cpp -lmingw32 -lSDL2main -lSDL2", and I have the SDL2.dll in the project folder (but NOT the src folder, just in the same folder as main.cpp and main.exe) but it doesn't work
If you are having other makefile problems such as your system not finding the file, or the 'make' command not working. installing 'GNU make' and restarting worked for me.
This is a VERY good tutorial. For Windows 11 users, as noted by @em_raaa below, be sure to use the include, lib, and SDL2.dll from the 64 bit folder. 32 bit won't compile. I would like to add that if you double-click the final exe from the GUI this SDL2 window will also open a console window. This can be resolved by adding the flag -mwindows to the Makefile. Maybe a lot of you already know that, but it was new to me. Cheers!
I tried this example, and I get this error when I run make: make : The term 'make' is not recognized as the name of a cmdlet, function, script file, or operable program. What could be the problem?
when i type make in terminal i get error :"make : The term 'make' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again."
Thumbs up because you used a makefile and not a json. Thank you, for understanding why we use vscode! Now if only microsoft could figure it out and stop turning it into visual studio! Subscribed too.
@@Prof.RafaelJunqueira First of all its makefile, not makerfile. And makefile is used across several ide's and is not only used to launch vscode. I stopped using makefile on windows in favor of the much simpler .bat files years ago. Secondly, json is a preference, not a requirement of programming. The more complex a piece of software becomes, the more a team is likely to depend on a custom data storage solution rather than the overly compatible but not optimized json. Not even xml is optimized. But you would know that, being an expert one what it takes to be a programmer, right? However, we use vscode to steer away from the cumbersome automation of Visual Studio and similar software like Rider, Mono and Eclipse. vscode implemented jsons are a step too close to such automation. I am not a fan of json in this sense. That is my preference, and I am thankful to work with a team who mostly shares that sentiment. I personally have two released games on steam, and have worked on more than 400 development projects in the last 7 years across 12 languages in 3 cities. So if I am not programmer, please, for the love of all that is good in the world, point me toward someone who is!
Here, a person @Zijie Lin wrote a solution to problems that most likely will arise for many. who got errors after makefile, you could: (1) use include, bin folders from folder x86_64-w64-mingw32 instead of the one selected in the video, because your computer identifies 64 bits version, not 32 bit version. (2) type comment "g++ -I src/include -L src/lib -o main main.cpp -lmingw32 -lSDL2main -lSDL2" directly into terminal instead of using makefile. (3) type comment "./main" in the terminal. But I would like to understand how to build and run all this as it should be and what is the problem of this error. For example, when I run the makefile that the author wrote, the system gives an error and the file main.cpp is deleted on its own. It is also very interesting how to install the same library in a C project. In addition, the author quietly runs the 'make' command, but I have to write 'mingw32-make' and no one says a word about it
@@SonarSystemsCoUk i'm using windows 11. This Makefile command all: g++ -I src/include -L src/lib -o main main.cpp -lmingw32 -lSDL2main -lSDL2 worked for me finally. Thank you for the video. If it's not hard for you. I'm trying to do the same thing but in C language and also include the nuklear library for building graphic elements in a window program. Nowhere did I find a similar video for C :(
OK so if you have an error like : undefined SDL_init and others like this, its because if you use SDL in 64 bits, you should download MinGW-64 bits version. In the video he uses a 32 bits version of SDL so if you have MinGW 32 bits there are no problems
holy shit that did it. I tried this a year ago but stopped because of this error, I started this again with the same error and was about to pull my hair out. Thank you so much!!
using 'make' just makes my main.cpp file to dissapear and shows error: undefined reference to `SDL_main' | collect2.exe: error: ld returned 1 exit status | make: *** [all] Blad 1
doesnt work on my side, i cant create the main.exe although im clicking on the quick fix. I wonder what I'm doing wrong, i have SDL2 setup nicely on Visual Studio but on vscode 2022 it doesnt work
I encountered this error: process_begin: CreateProcess(NULL, g++ -I src/include -L src/lib -o main main.cpp -lmingw32 -lSDL2main -lSDL2, ...) failed. make (e=2): The system cannot find the file specified. Makefile:2: recipe for target 'all' failed make: *** [all] Error 2 I still can't find the solution for it, can you give me some advice?
This was a great tutorial but when i do it it just always says fatal error: : No such file or directory 1 | #include it can't seem to find the #include, why??? please help me
I think for a lot of people getting compile issues(particularly the 'undefined reference to SDL_main') using the makefile----- just add the name of the file you are compiling (e.g. "g++ main.cpp ....") g++ main.cpp -I src\include -L src\lib -lmingw32 -lSDL2main -lSDL2 -o main
I have a problem in the line below it says: [{ "resource": "/d:/Programowanie/C++/SDLTemplate/main.cpp", "owner": "C/C++", "code": "165", "severity": 8, "message": "too few arguments in the function call", "source": "C/C++", "startLineNumber": 10, "startColumn": 128, "endLineNumber": 10, "endColumn": 128 }]. Does anyone know what is wrong with it? SDL_Window *window = SDL_CreateWindow( "Hello SDL World", SDL_WINDOWPOS_UNDEFINED, WIDTH, HEIGHT, SDL_WINDOW_ALLOW_HIGHDPI );
This works, only if I run the command from the Makefile in the terminal. I don't know why the "make" command doesn't work, and I can't set up the build task either, it gives me an error that says it cant find main.cpp, even though it finds it when I manually write it in the terminal. Anyone got the build task working?
This is the ONLY tutorial I've tried that has worked. Thank you! Only one question: when you write 'make' in the terminal are you calling CMake or are you using a VS Code extension?
I am working in C Language, and I want to use SDL for my semester project, I try to do all steps, but as I am writing the command make it is showing me error what should I do?
Hi, when i key in "make" i get the following error: make : The term 'make' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:1 + make + ~~~~ + CategoryInfo : ObjectNotFound: (make:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException
maybe u have mingw32-make.exe, just rename it to make.exe or just do make --version (which is not working for u) then do mingw32-make --version (this should work, check if u have downloaded and it exists in bin folder)
Tysm! This was extremely helpful, setting up sdl2 on my own was pretty much impossible. I got some issues though, like I could not get vscode to run my makefile, although if I paste the code from there into the terminal, it still works(idk why but whtvr)
For include error click on edit "IncludePath" and under "${workspaceFolder}/**" add "src/include" or where ever your include file is, make sure to add a comma. it works for me and might work for you idk
I have a question, in the case of this line "all: g++ -I src/include -L src/lib -o main main.cpp -lmingw32 -lSDL2main -lSDL2" Lets say If I wanted to change the main and main.cpp and alter it, for myself I put both files in a folder but since the path changed the file no longer run. How can I correctly alter and put the path into the makefile
The ONLY tutorial solved my problem in the past 2 weeks! However, I would like to know that how to solve the problem. When I run make, the cmd said command not found. How could I install it?
I had a lot of problems trying to get SDL2 running on my 64bit Windows 11 PC (with mingw64) using Visual Studio Code. I had a lot of problems(first with the make command, then main.exe error 0xc00007b), until I decided to install the 'SDL2-devel-2.30.0-VC.zip' (version for Visual Studio Code). Not sure if it was the include/lib folders or the 64-bit SDL2.dll file from that package, but it worked! Thought this might help some people.
What if i want to compile a C file? Should i replace g++ with gcc and main.cpp with main.c? Or is it more complicated than that? And also, i keep getting this undefined reference error (.text+0xaa) thing, i don't know what to do, as you see, i'm quite new at this.
make doesn't work because you are not using the name of the file you want to run. This is the correct command: g++ -I src/include -L src/lib -o main main.cpp -lmingw32 -lSDL2main -lSDL2 This is the wrong command: g++ -I src/include -L src/lib -o main.cpp -lmingw32 -lSDL2main -lSDL2 (this one misses the name of the file before main.cpp) if it still doesn't work the just open your folder and type ''cmd'' into the file directory and press enter then copy and paste the g++...... command on cmd, press enter then type the name of the file without the .cpp after and then press enter again, it will run your program and also create an .exe file.
The error message you mentioned typically occurs when the linker is unable to find a reference to the `SDL_CreateWindow` function. This error can be resolved by ensuring that you have properly set up the SDL library in your project. Here are some steps you can follow to fix this issue: 1. Check SDL Installation: Verify that you have installed the SDL library correctly on your system. Make sure you have the necessary header files and libraries. 2. Linker Configuration: Ensure that you have properly configured the linker settings in your project. You need to specify the correct library to link with your code. For SDL, you typically need to link with the SDL library and its related libraries. In CMake, you can add the following lines to your `CMakeLists.txt` file: ```cmake find_package(SDL2 REQUIRED) target_link_libraries(your_project_name SDL2) ``` In GCC or G++, you can use the `-l` flag to specify the SDL library: ``` gcc your_file.c -o your_executable -lSDL2 ``` Make sure you are linking against the correct version of SDL that you have installed. 3. Include SDL Headers: Verify that you have included the correct SDL header file in your source code. You should have the following line at the top of your source file: ```c #include ``` 4. Check Build Process: Ensure that you are correctly compiling and linking your code. If you are using an IDE, make sure the necessary build steps are configured properly. By following these steps, you should be able to resolve the "undefined reference to SDL_CreateWindow" error. Remember to double-check your SDL installation and make sure you have the correct version of the library and headers.
my vsCode doesnt reconize any of the commands you can type in the terminal i have to manually copy paste the make file into the terminal for it to work. Is there something i need to install? Or have i installed something incorrectly?
"make" and "./main" doesn't work. I have to copy paste it from the MakeFile into the terminal manually. Also, when I run the program a cmd opens up with it...
I found a solution, I think. So yesterday I installed a program called "GNU make" via something called chocolaty. And after turning off my computer and starting it today the command works now. So does ./main. So, if you are having the same problems with make not working try installing 'GNU make' and restarting. And make sure your makefile is named "makefile" or has the file extension *.mk.
when i typed make on the terminal it just gave an error saying"The term 'make' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was inclu ded, verify that the path is correct and try again." do you guys know the reason
Very good video but I'm still having trouble getting the make command to run. I tried running g++ -I src/include -L src/lib -o main main.cpp -lmingw32 -lSDL2main -lSDL2 directly into the terminal but g++ was not recognized. Everything else is identical to what has been shown ({worspace}src/include in the header path and the SDL.dll in same location as main). I am not sure what else I am missing unless minGW needs to be installed into vsCode separately.
yea nope still not working for me why did we even copy the folder in the beginning and stuff the way you explain it feels somehow so confusing, I know less than before
I've been trying to add SDL_image on VS Code using this setup, but it hasn't been working. I installed SDL_image using MSYS2 as well as SDL and copy pasted the include and lib files to my src folder. Well everything works well I can even write commands from SDL_image such as IMG_LoadTexture, and it wont show me anything thats wrong. Its all fine and dandy until I run the code, I do ./main, and... nothing. I have put warning outputs if its null, but thats not it. It just, doesnt do anything. If I remove all functions from SDL_image, the code works fine. As long as we never mention anything from SDL_image, it works. Do you know how this can be fixed?
If like me, anyone else was greeted by this when we type make in the terminal, make : The term 'make' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:1 + make + ~~~~ + CategoryInfo : ObjectNotFound: (make:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException _________________ Then use MinGW32-make instead of make
I got the error: undefined reference to `WinMain@16' collect2.exe: error: ld returned 1 exit status make: *** [Makefile:2: all] Error 1 I have saved my file, however the error persists. Any ideas?
- try using the 32 bit sdl files (i686-w64-mingw32) instead of the 64bit ones from the tutorial. - make sure your main function looks like: int main(int argc, char **argv) (remember no caps in main function eg mAin()). that's all i got hope it helps :D
@@SonarSystemsCoUk SDL2 2.26.5 "includePath": [ "${workspaceFolder}/**", "${workspaceFolder}/src/include" ], this in .json i think i did it right idk why it dont work
thx for tutor Find video where man resolved undefined reference to `WinMain' problem by added #define SDL_MAIN_HANDLED in top of main.cpp file and it worked for me.
make : The term 'make' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:1 I don't know what to say
if yall are having trouble with the #include try and just use #include this way worked for me, and I'm thinking that's how they now do it with 2.30 version.
you started the tutorial with already downloading the SDL dev file? yet telling people how to download visual studio? cmon man. it would be helpful if you explained why you got the mingw version, etc.
What if we want to use SDL2 on the X64 version, so that it can use more than 4gb of RAM? Surely this version would be better? How do I get an x64 version of MinGW to use it with?
make doesn't get recognized by terminal, i tried copy pastying Makefile command but i get the following error: skipping incompatible src/lib/libSDL2.dll.a when searching for -lSDL2... Any geniuses in the chat????????? seriously begging ,been stuck on this for a second day...
I read "That message isn't actually an error - it's just a warning that the file in question isn't of the right architecture (e.g. 32-bit vs 64-bit, wrong CPU architecture). The linker will keep looking for a library of the right type.". So I instead of using the 32-bit folder, I followed all the instructions using the 64-bit folder.
for everyone who got errors after makefile, you could: (1) use include, bin folders from folder x86_64-w64-mingw32 instead of the one selected in the video, because your computer identifies 64 bits version, not 32 bit version. (2) type comment "g++ -I src/include -L src/lib -o main main.cpp -lmingw32 -lSDL2main -lSDL2" directly into terminal instead of using makefile. (3) type comment "./main" in the terminal.
Thank you for sharing
That was very helpful but do you have any tips with how to turn on the main.exe but it keeps getting "This application couldn't start properly"
Thank you!! you just saved my day!
Sir, you are literally a blessing to humanity. You are like my guiding star, illuminating my path and filling my world with joy. Your presence brings a warmth that melts my heart and a smile that brightens my day. I'm grateful to have crossed paths with someone as captivating as you.
if the command "make" doesn't work for you, try typing "mingw32-make" instead.
if you want to use it by typing "make", what I did was to duplicate the file "mingw32-make.exe" located in "C:\MinGW\bin" and rename it to "make.exe".
it's probably not the cleanest but it is simple and it worked for me.
i installed my mingw compiler from sourceforge it doesnt have mingw32-make
@@6H075T2 run mingw32-get install maingw32-make
OMMMMMMMMMMMMMMMMMGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG THANK YOU SO MUCH I WAS TRYING TO FIGURE OUT WHY IT WASN'T WORKING FOR DAYS AND YOU JUST HELP SAVE MY LIFEEEEEEEEE THANK YOUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU :)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
@@yikiangaming3981 I'm glad it helped you :)
You can change the name of that "mingw32-make.exe" file to "make.exe" and then you can just run the command "make" from the command line as long as you add it to the path correctly.
I had been struggling to get SDL2 to work in Eclipse for days, before I finally broke down and transitioned to Visual Studio Code. Your video was quick, clear, and informative; thank you!
broke down with geany here
for me it been years
Bro, I was waiting for you, Godsend man. There were always tutorials for Visual studio, or VSC that weren't that good. This one slaps, like the details, testing if it works and explaining along the way. Giving it a thumbs up!
Thank you very much from japan.
I had difficulty in using SDL2 and searched for how to use it. Then, I found this video and I can solved this problem. I really appreeciate it.
If you are facing issues running building the Makefile then try the below steps:
1. Copy the i686-w64-mingw32/lib and /include folder into the src folder of your VSCODE project. Make sure you copy the lib and include folders manually instead of dragging and dropping it in VSCode. The folder structure is important i.e src/include and src/lib
2. Copy the i686-w64-mingw32/bin/SDL2.dll from the bin folder to your project folder.
3. For me, g++ was not working so I used gcc in the Makefile and finally got to work.
Happy game development!
thx
Thanks! This worked for me
I get the error "No such file or directory #include ", how to fix this error?
I've got an error just like this and can't find anything on stack overflow on how to address this. Is this tutorial out of date? Error: "SDL2/SDL.h: No such file or directory' @SonarSystemsCoUk
I had the same error. Worked out the solution was that I had made a couple of typos in the Makefile file. I had missed a '-' and also I had named my folder SRC not src, so needed to correct that.
If you're STILL getting errors even after using the 64 version of SDL2, then (1) replace your PATH variable for mingw/bin with the one for mingw64/bin. (2) Just add mingw64/bin to PATH variable without replacing the mingw/bin, and rename the g++ in mingw64/bin to something like g++64 and then change your command from (g++ main.cpp) to (g++64 main.cpp)
This issue happened to me because I installed minGW first, then later installed minGW64
TO EVERYONE WHO GOT THE ERROR AFTER THE MAKE FILE
if you are on windows 11 make sure you are using the 64 bit version of SDL as the 32 is not supported.. 32 bit version is selected in this tutorial
anything else that needs to be changed to make this work? I'm getting an error now when I try to use ./main, which when looked up everyone says its the wrong OS and that the json file needs to be edited. Any advice?
@@jozburn7503 hmm make sure you put the SDL.dll from the 64 bit folder as well. this worked for me, also make sure you delete the broken exe if it made one
@@em_raaa my compile line is "g++ -I src/include -L src/lib -o main main.cpp -lmingw32 -lSDL2main -lSDL2", and I have the SDL2.dll in the project folder (but NOT the src folder, just in the same folder as main.cpp and main.exe) but it doesn't work
i love you
If you are having other makefile problems such as your system not finding the file, or the 'make' command not working. installing 'GNU make' and restarting worked for me.
This is a VERY good tutorial. For Windows 11 users, as noted by @em_raaa below, be sure to use the include, lib, and SDL2.dll from the 64 bit folder. 32 bit won't compile. I would like to add that if you double-click the final exe from the GUI this SDL2 window will also open a console window. This can be resolved by adding the flag -mwindows to the Makefile. Maybe a lot of you already know that, but it was new to me. Cheers!
Thank you!
OMGG THANK YOUU
I tried this example, and I get this error when I run make: make : The term 'make' is not recognized as the name of a cmdlet, function, script file, or operable program. What could be the problem?
you dont have mingw or probably a compiler installed
@@adamsalem-s I have download both the vs code and mingw but still it is saying that sdl2 header file cannot be recognized
can you help me out? please
when i type make in terminal i get error :"make : The term 'make' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of
the name, or if a path was included, verify that the path is correct and try again."
same
@@Rhapsolin use mingw32-make
it finally worked, thanks for the tutorial!
it's so clear and full of useful explanations!! thank you, you're a lifesaver!!
Thumbs up because you used a makefile and not a json. Thank you, for understanding why we use vscode! Now if only microsoft could figure it out and stop turning it into visual studio! Subscribed too.
Awesome to hear it helped
If you don't use json, you are not a programmer, is a final user. Json is used for all applications. Makerfile is use only on vscode.
@@Prof.RafaelJunqueira First of all its makefile, not makerfile. And makefile is used across several ide's and is not only used to launch vscode. I stopped using makefile on windows in favor of the much simpler .bat files years ago.
Secondly, json is a preference, not a requirement of programming. The more complex a piece of software becomes, the more a team is likely to depend on a custom data storage solution rather than the overly compatible but not optimized json. Not even xml is optimized. But you would know that, being an expert one what it takes to be a programmer, right?
However, we use vscode to steer away from the cumbersome automation of Visual Studio and similar software like Rider, Mono and Eclipse. vscode implemented jsons are a step too close to such automation.
I am not a fan of json in this sense. That is my preference, and I am thankful to work with a team who mostly shares that sentiment. I personally have two released games on steam, and have worked on more than 400 development projects in the last 7 years across 12 languages in 3 cities. So if I am not programmer, please, for the love of all that is good in the world, point me toward someone who is!
Quite contrary to the norm, especially for older tutorials, this setup worked like a charm. Thanks.
Here, a person @Zijie Lin wrote a solution to problems that most likely will arise for many. who got errors after makefile, you could: (1) use include, bin folders from folder x86_64-w64-mingw32 instead of the one selected in the video, because your computer identifies 64 bits version, not 32 bit version. (2) type comment "g++ -I src/include -L src/lib -o main main.cpp -lmingw32 -lSDL2main -lSDL2" directly into terminal instead of using makefile. (3) type comment "./main" in the terminal.
But I would like to understand how to build and run all this as it should be and what is the problem of this error. For example, when I run the makefile that the author wrote, the system gives an error and the file main.cpp is deleted on its own.
It is also very interesting how to install the same library in a C project.
In addition, the author quietly runs the 'make' command, but I have to write 'mingw32-make' and no one says a word about it
What computer are you using?
@@SonarSystemsCoUk i'm using windows 11. This Makefile command all:
g++ -I src/include -L src/lib -o main main.cpp -lmingw32 -lSDL2main -lSDL2 worked for me finally. Thank you for the video. If it's not hard for you. I'm trying to do the same thing but in C language and also include the nuklear library for building graphic elements in a window program. Nowhere did I find a similar video for C :(
@@aleksandrnikolaev2914 thanks, this worked for me
Thanks a lot!
great explaination! we need more people like you
;)
Screw SDL, use Raylib. Piece of cake to set it up and way more fun to code with it.
thank you very much you helped me alot man!
SDL.cpp:2:10: fatal error: SDL2/SDL.h: No such file or directory
2 | #include
bro me too wtf
I saw that vimm's lair 👀good choice, good choice
fatal error: SDL2/SDL.h: No such file or directory
OK so if you have an error like : undefined SDL_init and others like this, its because if you use SDL in 64 bits, you should download MinGW-64 bits version. In the video he uses a 32 bits version of SDL so if you have MinGW 32 bits there are no problems
thxxx
holy shit that did it. I tried this a year ago but stopped because of this error, I started this again with the same error and was about to pull my hair out. Thank you so much!!
using 'make' just makes my main.cpp file to dissapear and shows error: undefined reference to `SDL_main' | collect2.exe: error: ld returned 1 exit status | make: *** [all] Blad 1
Were u able to solve it ?
Thanks a lot dude. Went through many videos none of them seems to work. This one made my day. Great content keep it up.
thanks a lot, this worked, the comment section also helped.
Glad it helped
doesnt work on my side, i cant create the main.exe although im clicking on the quick fix. I wonder what I'm doing wrong, i have SDL2 setup nicely on Visual Studio but on vscode 2022 it doesnt work
My program says that no such file as SDL2/SDL.h and I have done everything shown in the video
ifr you arent on linux then do sdl.h directly
I encountered this error:
process_begin: CreateProcess(NULL, g++ -I src/include -L src/lib -o main main.cpp -lmingw32 -lSDL2main -lSDL2, ...) failed.
make (e=2): The system cannot find the file specified.
Makefile:2: recipe for target 'all' failed
make: *** [all] Error 2
I still can't find the solution for it, can you give me some advice?
When does this occur?
@@SonarSystemsCoUk It showed up when I entered the make command in terminal
You're a lifesaver, thank you so much dude! Have a nice day :)
anyone know how to fix the issue "No such file or directory" for #include
help me too if you fixed it
Same here ✋
@Melina ABC ive tried that and basically every other variation of it but nothing seems to work
use 64 bit version of sdl if you are on windows 11
@@em_raaa doesn't help
This was a great tutorial but when i do it it just always says fatal error: : No such file or directory
1 | #include
it can't seem to find the #include, why??? please help me
I have the same error.
help !!!
stackoverflow.com/questions/10488775/sdl-h-no-such-file-or-directory-found-when-compiling
stackoverflow.com/questions/10488775/sdl-h-no-such-file-or-directory-found-when-compiling
Same error help someone
Great video, more content about sdl2
More to come! Making one right now
I think for a lot of people getting compile issues(particularly the 'undefined reference to SDL_main') using the makefile----- just add the name of the file you are compiling (e.g. "g++ main.cpp ....")
g++ main.cpp -I src\include -L src\lib -lmingw32 -lSDL2main -lSDL2 -o main
I had this issue. The main.cpp was at the end, so moving it just after the g++ seems to have fix it. Thanks!
i'm still having the same compilation issues (undefined reference to `SDL_Init' ....) after doing what you've mentioned
This solved my problem Thank you!
I have a strange problem, I did everything as said, but I get the error:
main.cpp:2:22: fatal error: SDL2/SDL.h: No such file or directory
#include
^
Did you follow all the steps?
@Hamza lol it was the letter L un-capitalized
@@bofoitakoyaki9859 where i shall put? L
@@ijnokm7903 watch carefully when he is creating the makefile. do it letter by letter
Thank You very much, I struggled a lot to get sdl2.
I have a problem in the line below it says:
[{
"resource": "/d:/Programowanie/C++/SDLTemplate/main.cpp",
"owner": "C/C++",
"code": "165",
"severity": 8,
"message": "too few arguments in the function call",
"source": "C/C++",
"startLineNumber": 10,
"startColumn": 128,
"endLineNumber": 10,
"endColumn": 128
}].
Does anyone know what is wrong with it?
SDL_Window *window = SDL_CreateWindow( "Hello SDL World", SDL_WINDOWPOS_UNDEFINED, WIDTH, HEIGHT, SDL_WINDOW_ALLOW_HIGHDPI );
pozdro
This works, only if I run the command from the Makefile in the terminal. I don't know why the "make" command doesn't work, and I can't set up the build task either, it gives me an error that says it cant find main.cpp, even though it finds it when I manually write it in the terminal. Anyone got the build task working?
to get make in windows
run mingw32-get install mingw32-make
go to C:\mingw\bin and replace wingw32-make with make
VSCode couldnt find the libs. So i imported them from the x86_64 folder instead and then it worked
Thanks for saying this. It saved me quite a bit of time flailing around. I coped over the other files and it worked instantly.
Thankyou so much man!!!
This is the ONLY tutorial I've tried that has worked. Thank you!
Only one question: when you write 'make' in the terminal are you calling CMake or are you using a VS Code extension?
it is a g++ command for running makefiles
@@shreyashosahalli1222 thanks for responding. Since I asked this question I fell down the whole mingw32-make, make, MakeFile, CMake rabbithole.
which one exactly is it? I can't seem to get it to work either, if you solved it can you please reply? Thanks so much in advance!
I am working in C Language, and I want to use SDL for my semester project, I try to do all steps, but as I am writing the command make it is showing me error what should I do?
Really helpful, thank you for the video !
Glad it was helpful!
After running mingw32-make It said cannot find -lSDL2: No such file or directory
Make sure your file like this:
your_project_directory/
├── main.c
├── src/
├── include/
│ └── SDL2/
│ └── SDL.h
└── lib/
└── libSDL2.a
└── Makefile
how to fix no such file or directory?
I am getting an error when typing the "make" command. Then I downloaded minGW to try and solve it and it still didn't work? Could you help me?
I had the same issue as you have. Try using "mingw32-make" instead of "make". I hope it works for you as it did for me
@@mudu3271 Thanks I tried but now its saying g++: fatal error: no input files. But maybe I missed something
@@mudu3271 I was getting the same problem Walter did, your tip solve my issue, thank you very much!
Hi, when i key in "make" i get the following error: make : The term 'make' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that
the path is correct and try again.
At line:1 char:1
+ make
+ ~~~~
+ CategoryInfo : ObjectNotFound: (make:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
I have the same error, very confused
I just used the same command ("make") in my cygwin terminal and it worked perfectly
maybe u have mingw32-make.exe, just rename it to make.exe
or just do make --version (which is not working for u)
then do mingw32-make --version (this should work, check if u have downloaded and it exists in bin folder)
Tysm! This was extremely helpful, setting up sdl2 on my own was pretty much impossible. I got some issues though, like I could not get vscode to run my makefile, although if I paste the code from there into the terminal, it still works(idk why but whtvr)
I have a problem of "THIS APP CANT RUN ON YOUR PC" can anyone guide about this
For include error click on edit "IncludePath" and under "${workspaceFolder}/**" add "src/include" or where ever your include file is, make sure to add a comma. it works for me and might work for you idk
BRO THANK YOU OH MY GOD YOU DONT UNDERSTAND HOW LONG IT TOOK FOR THIS TO WORK AND NO ONE MENTIONS IT ACTUAL LIFE SAVER
@@mouhanadatrash358thanks, Good luck on ur coding journey
I have a question, in the case of this line
"all:
g++ -I src/include -L src/lib -o main main.cpp -lmingw32 -lSDL2main -lSDL2"
Lets say If I wanted to change the main and main.cpp and alter it, for myself I put both files in a folder but since the path changed the file no longer run. How can I correctly alter and put the path into the makefile
when i try to compile it just returns with not existing as a file or directory, also im using C so i have to make some adjustments i know
have you fixed this, i got the same error
@@ricardo1084honestly forgot how i fixed it, but if you come to the server, i can help
The ONLY tutorial solved my problem in the past 2 weeks!
However, I would like to know that how to solve the problem.
When I run make, the cmd said command not found. How could I install it?
Me too I have everything installed and i attempted to use the command and I got the same error
@@magnuslaue3334 mingw32-make seems useful but its a bit too long
I reinstalled my gcc and it ran properly at last
I had a lot of problems trying to get SDL2 running on my 64bit Windows 11 PC (with mingw64) using Visual Studio Code. I had a lot of problems(first with the make command, then main.exe error 0xc00007b), until I decided to install the 'SDL2-devel-2.30.0-VC.zip' (version for Visual Studio Code). Not sure if it was the include/lib folders or the 64-bit SDL2.dll file from that package, but it worked! Thought this might help some people.
I have to download that and then follow the video, right? Plz, respond
@@cmtdao442At least that's what I did. Just use the include and lib folders from the VSC version instead of the version mentioned in the video.
What if i want to compile a C file? Should i replace g++ with gcc and main.cpp with main.c? Or is it more complicated than that? And also, i keep getting this undefined reference error (.text+0xaa) thing, i don't know what to do, as you see, i'm quite new at this.
Program compiles correctly but cannot launch
No string were prompted in the terminal.
What string?
make doesn't work because you are not using the name of the file you want to run.
This is the correct command:
g++ -I src/include -L src/lib -o main main.cpp -lmingw32 -lSDL2main -lSDL2
This is the wrong command:
g++ -I src/include -L src/lib -o main.cpp -lmingw32 -lSDL2main -lSDL2
(this one misses the name of the file before main.cpp)
if it still doesn't work the just open your folder and type ''cmd'' into the file directory and press enter then copy and paste the g++...... command on cmd, press enter then type the name of the file without the .cpp after and then press enter again, it will run your program and also create an .exe file.
i got this error "undefined reference to SDL_CreateWindow" someone know how to fix this.
The error message you mentioned typically occurs when the linker is unable to find a reference to the `SDL_CreateWindow` function. This error can be resolved by ensuring that you have properly set up the SDL library in your project.
Here are some steps you can follow to fix this issue:
1. Check SDL Installation: Verify that you have installed the SDL library correctly on your system. Make sure you have the necessary header files and libraries.
2. Linker Configuration: Ensure that you have properly configured the linker settings in your project. You need to specify the correct library to link with your code. For SDL, you typically need to link with the SDL library and its related libraries.
In CMake, you can add the following lines to your `CMakeLists.txt` file:
```cmake
find_package(SDL2 REQUIRED)
target_link_libraries(your_project_name SDL2)
```
In GCC or G++, you can use the `-l` flag to specify the SDL library:
```
gcc your_file.c -o your_executable -lSDL2
```
Make sure you are linking against the correct version of SDL that you have installed.
3. Include SDL Headers: Verify that you have included the correct SDL header file in your source code. You should have the following line at the top of your source file:
```c
#include
```
4. Check Build Process: Ensure that you are correctly compiling and linking your code. If you are using an IDE, make sure the necessary build steps are configured properly.
By following these steps, you should be able to resolve the "undefined reference to SDL_CreateWindow" error. Remember to double-check your SDL installation and make sure you have the correct version of the library and headers.
It worked thanks
sir, how to do make ?
"No Targets specified and no makefile found, Stop." with make
specifying the actual MakeFile gives me:
"Nothing to be done for 'MakeFile'."
did you solve it?
@@BenBerke no, lol, gave up 💀
(I programmed my silly little game idea in Godot instead)
@@BenBerke it's an easy fix! change the file directory in the terminal -->
cd (location of your project)
Hope this helps ;))
my vsCode doesnt reconize any of the commands you can type in the terminal
i have to manually copy paste the make file into the terminal for it to work. Is there something i need to install? Or have i installed something incorrectly?
"make" and "./main" doesn't work. I have to copy paste it from the MakeFile into the terminal manually. Also, when I run the program a cmd opens up with it...
I found a solution, I think. So yesterday I installed a program called "GNU make" via something called chocolaty. And after turning off my computer and starting it today the command works now. So does ./main. So, if you are having the same problems with make not working try installing 'GNU make' and restarting. And make sure your makefile is named "makefile" or has the file extension *.mk.
Thanks for sharing
when i typed make on the terminal it just gave an error saying"The term 'make' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was inclu
ded, verify that the path is correct and try again." do you guys know the reason
Same issue, did you find a solution?
thanks but i have a question:
I want to use the mingw-w64 instead of mingw-w32. How can i do that 😀😀
Either will work, same process.
@@SonarSystemsCoUk so i just need to replace mingw-w32 by mingw-w64?
I get to error "Program 'main.exe' failed to run: the file or directory is corrupted and unreadable...
pls how to I solve this?? 🤕
its now SDL3 its working only the SDL_Image wont work.... fatal error: SDL_image.h: No such file or directory
Thanks it helped me a lot!!
Very good video but I'm still having trouble getting the make command to run. I tried running g++ -I src/include -L src/lib -o main main.cpp -lmingw32 -lSDL2main -lSDL2 directly into the terminal but g++ was not recognized. Everything else is identical to what has been shown ({worspace}src/include in the header path and the SDL.dll in same location as main). I am not sure what else I am missing unless minGW needs to be installed into vsCode separately.
yea nope still not working for me
why did we even copy the folder in the beginning and stuff
the way you explain it feels somehow so confusing, I know less than before
I've been trying to add SDL_image on VS Code using this setup, but it hasn't been working. I installed SDL_image using MSYS2 as well as SDL and copy pasted the include and lib files to my src folder. Well everything works well I can even write commands from SDL_image such as IMG_LoadTexture, and it wont show me anything thats wrong. Its all fine and dandy until I run the code, I do ./main, and... nothing. I have put warning outputs if its null, but thats not it. It just, doesnt do anything. If I remove all functions from SDL_image, the code works fine. As long as we never mention anything from SDL_image, it works. Do you know how this can be fixed?
why is my launched window in black in instead of white like yours?
help!!! when i run the exe file disappear and
it says launch:program "exe file" does not exist
Thank you!One question , now if i make a c++ program using SDL library anywhere in my PC i just have to include the library,no?
If like me, anyone else was greeted by this when we type make in the terminal,
make : The term 'make' is not recognized as
the name of a cmdlet, function, script file,
or operable program. Check the spelling of the
name, or if a path was included, verify that
the path is correct and try again.
At line:1 char:1
+ make
+ ~~~~
+ CategoryInfo : ObjectNotFound:
(make:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
_________________
Then use MinGW32-make instead of make
Thanks for sharing
g++ -I src/include -L src/lib -o main main.cpp -lmingw32 -lSDL2main -lSDL2
src/lib/libSDL2main.a(SDL_windows_main.o): In function `main_getcmdline':
/Users/valve/release/SDL2/SDL2-2.26.3-source/foo-x64/../src/main/windows/SDL_windows_main.c:82: undefined reference to `SDL_main'
collect2.exe: error: ld returned 1 exit status
Makefile:2: recipe for target 'all' failed
mingw32-make: *** [all] Error 1
_____________________
help me, please!
@@nhuthaophan5077 could you solve it?
i have the same problem so i'd appreciate if you shared the solution
I got the error:
undefined reference to `WinMain@16'
collect2.exe: error: ld returned 1 exit status
make: *** [Makefile:2: all] Error 1
I have saved my file, however the error persists.
Any ideas?
Try using MinGW32-make instead of make
What's the exact error?
- try using the 32 bit sdl files (i686-w64-mingw32) instead of the 64bit ones from the tutorial.
- make sure your main function looks like: int main(int argc, char **argv) (remember no caps in main function eg mAin()).
that's all i got hope it helps :D
@@evolve-yt Hey! Can you explain why using the 32bit files works but not the 64bit?
i hate setting up these
main.cpp:1:10: fatal error: SDL2/SDL.h: No such file or directory
1 | #include
i
What version of everything are you using?
@@SonarSystemsCoUk SDL2 2.26.5
"includePath": [
"${workspaceFolder}/**",
"${workspaceFolder}/src/include"
],
this in .json
i think i did it right idk why it dont work
thx for tutor
Find video where man resolved
undefined reference to `WinMain' problem by added
#define SDL_MAIN_HANDLED
in top of main.cpp file and it worked for me.
I am getting a fatal problem which is no such a file or directory
Where do you get this error?
Hi, do you have any tips with how to turn on the main.exe 'cause it keeps getting "This application couldn't start properly"
Pls help me:(
When does this occur, how are you trying to launch it?
Why it is saying missing separator when I use make
doing mingw32-make just...deleted main.cpp? what in the
make : The term 'make' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of
the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
I don't know what to say
you left me speechless
same for me
run mingw32-get install mingw32-make
go to C:\mingw\bin and replace wingw32-make with make
@@DeltaEchoVictor Could you provide me specific instructions?
if yall are having trouble with the #include try and just use #include this way worked for me, and I'm thinking that's how they now do it with 2.30 version.
you started the tutorial with already downloading the SDL dev file? yet telling people how to download visual studio? cmon man. it would be helpful if you explained why you got the mingw version, etc.
Why?
@@SonarSystemsCoUk Have you already installed the gcc compiler? and you are using that instead of the visual c++ compiler? Theres missing info here
does it work with c also ?
What if we want to use SDL2 on the X64 version, so that it can use more than 4gb of RAM? Surely this version would be better? How do I get an x64 version of MinGW to use it with?
when I type make in terminal make it gets errors, please help me
God bless you man
what do you do
man you have tons of petabyte still you're running outta space
The realeases page is not working anymore, can someone help me?
What happens?
@@SonarSystemsCoUk when you click "realeases" it takes you directly to github and after downloading the folder the "lib" folder is missing
We're just gonna ignore the NFT folder?
What folder, first rule of folder club is we don't talk about folders
make doesn't get recognized by terminal, i tried copy pastying Makefile command but i get the following error: skipping incompatible src/lib/libSDL2.dll.a when searching for -lSDL2...
Any geniuses in the chat????????? seriously begging ,been stuck on this for a second day...
I read "That message isn't actually an error - it's just a warning that the file in question isn't of the right architecture (e.g. 32-bit vs 64-bit, wrong CPU architecture). The linker will keep looking for a library of the right type.". So I instead of using the 32-bit folder, I followed all the instructions using the 64-bit folder.
@@johnnyl2903 Thank you. Now it worked.
thanks bro, visual studio code is very powerfull.
It is indeed, enjoy
include problem any solution?
How do you do it for C
mine is giving undefined reference to SDL_Init, CreatWindow
its need to put the sdl bin into environment path?
You are the best
hi problem make command is not working please can you help me
if you are on windows 11 make sure you are using the 64 bit version
of sdl