How to setup Codeblocks mingw SDL2.0

preview_player
Показать описание
This tutorial is an update of my previous video for setting up codeblocks mingw and SDL2.0.
The correct project settings are listed in the link below.
Support me on Patreon if you would like to see more of these videos

Рекомендации по теме
Комментарии
Автор

*-lmingw32 -lSDL2main -lSDL2 -lSDL2_image -lSDL2_mixer*

Can't see what is at 6:00 . Here you go.

Vote this comment up, so that people can copy the linker settings for themselves.

MisterClassified
Автор

I didn't remember I already had CodeBlocks, so I installed it again while following this tutorial. I did everything exactly like adviced but it didn't work (SDL.h not found).

I did "powerfull uninstall" for CodeBlocks (win7). Basically same thing as normal uninstall of a program and deleting all remaining files and folders. After that I did everything just like before and just like adviced in this tutorial - but used drive D.

And then everything worked.

So the problem is in Windows or CodeBlocks itself (or with previous versions or something like that) and not in your tutorial or in people who follow these instructions.

Since many people have had this "SDL.h not found" error I would like to recommend same uninstall/install method I used.

NOTE: If you install CodeBlocks to some other drive than C you need to change drive letter and/or path from Settings -> Compiler -> Toolchain executables -> "Compiler's installation directory".

Thank you for your tutorial.

jonihietala
Автор

Thank you for the tutorial George. I could successfully build a program that renders an SDL window. However the text version of the tutorial for more clarity and desirable pace :)

sreekarguddeti
Автор

Very nice.  What I like to do for my projects is to create a debug build which compiles as a console app so I can display debug info in the console screen, and I create a seperate release build which compiles it as a GUI app.  This way I do all my testing with my console screen up, and when it is working fine, I can switch to the release build and compile that separately.  You can also create 32 and 64 bit release build options as well although I have not dived into 64 bit compiling yet, though I want to learn it.  Love Code::Blocks.  New to SDL though.  Looking forward to diving into it and trying it out.  Thanks for the videos.

NeilRoy
Автор

Good tutorial, though kind of hard to see, really glad there was a text version. I found an error and managed to fix it (in case anyone has the same issue).

If you copy the code for the files directly from the text version and try to build in Code Blocks it will give you several errors due to extra spaces, I don't have them all written down, but some examples are below.

#include < SDL.h > causes an error, works as #include <SDL.h>
comment blocks / * * / don't register with spaces
namespaces don't register with spaces, for instance game : : game -> game :: game
comparison doesn't work with spaces "renderer = = NULL" -> "renderer == NULL "

I imagine this was a problem caused when the tutorial was uploaded rather than when it was written as a lot of the web-hosting sites have been adding strange formatting lately (I know an author friend has been having similar troubles with his blog).

brainiacgmail
Автор

Hello George,

I have downloaded the example code SDL201. Could build and run without any problem. 

Minor Correction: The side heading under which the link to the example code appears says "A simple project to display a triangle". The text below that says " how to code a simple SDL window". The latter is the observed behaviour. Since I had not read the sentence before building and executing, I thought there was something amiss. So I quickly walked thru the code and saw no evidence of a triangle being generated. Sometimes defects in documentation can have positive side-effects:-)

Now proceeding to the other tutorials on your playlist, the link to which you have very helpfully provided.

Thank you & keep up the good work.

rmnair
Автор

I'm having some trouble when I try to compile...every time it says it "cannot find -lSDL2main.lib".  I have checked the settings and can find nothing wrong.  I am using the correct SDL_platform.h file and have checked and rechecked my includes, libraries, settings, etc. and can't find anything...your tutorials all vary slightly with this video using 3 SDL libraries, the settings text file only 2, and your text tutorial using 4, so I'm not sure if I somehow mixed these in a weird way or...I'm just lost.

hoekz
Автор

If I wanted to set this up on a hard drive so I could just take the hard drive and continue working on the project on any computer with Code:Blocks on it, How would I go about that?

lorenzojojoba
Автор

Hey I did exactly as you explained and downloaded your project, and when I run it, it works fine, but when I rebuild the project (or change a file and then build and run) it sais: "fatal error: SDL2/SDL.h: No such file or directory" (in the file "includes.h" at line 4). Do you know what might cause this? I even put the SDL folder right on my C: disk like you did. Please help

Winfinitely
Автор

when I try compile it this say "SDL_main.h: no such file", then it does not found any directory in sdl.h, but I have linked like you explain in "settings".  What is the problem?

AlixAA
Автор

I'm trying to install SDL for a long time, but always at the end of any tutorial i got error "SDL.h: No such file or directory". So I found your tutorial (and I saw this about SDL_platform.h) and I done everything step-by-step. At the end again i got "SDL.h: No such file or directory". I tried even using 2.0.2 version instead of 2.0.3 but still I'm getting this error. Can you suggest any solution of problem?

Kajoj
Автор

Codeblocks, Windows 8. I installed the i686 versions of SDL. I've included links to my /include/SDL/, /include/, and /lib/ folders in the appopriate places in my compiler's search directory area, and I've copied the -lSDL (etc) tags exactly as you've written them in this video. I've also copied all necessary DLL's into the folder where my Hello World SDL program lives. At the top of my code, is #include <sdl.h>, though I've also tried #include "sdl.h". When I try to compile, I get the error that there is "no such file or directory" as SDL.h. Even if I copy all of the above data into the project's build options, as well as the compiler options.

Any idea what I'm doing wrong? How bad of an idea is it to copy SDL.h into my working directory?

oddbirdMusic
Автор

followed your tutorial and everything compiles just fine, but no window is being created when the program runs and no errors are displayed.

also your links to grhmedia.com don't seem to work.

insanejunkie
Автор

I'm getting the "winapifamily.h: No such file or directory" error. I google it, and it seems that everybody assumes people are using Codeblocks under Windows 8, but I am using Win7 32 bits. Any idea on how to solve this problem?

profzeco
Автор

Hey George Hayes! I tried to bulid a program with sdl and it says ld has stopped working. What does that mean?

slayerdragon
Автор

Oh! Cool! The linker options fixed my undefined reference error.

zirzachtheman
Автор

This is featured on the official SDL page

byrussx
Автор

hey man! i got code blocks setup fine and i got sdl as well. But when i try to compile it tells me cannot find lSDL2main, lSDL2_image etc.. will be glad if you could help me out.

dheerajdhall
Автор

||=== Build: Debug in GameEngine_1.0.0 (compiler: GNU GCC Compiler) ===|
error: winapifamily.h: No such file or directory|
||=== Build failed: 1 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|

how can this error be fixed?

alexhelmacy
Автор

I have a simple program that includes the SDL2/SDL.h header and when i try to build it says "fatal error: winapifamily.h: No such gile or directory"

shahars
visit shbcf.ru