User forums > Help
Cannot get SDL to work in MinGW
(1/1)
JonMW:
When I began dabbling in C, I would write directly with notepad and compile with DJGPP - this worked well enough for the extremely small programs that I wrote at home for my own amusement. Eventually, I worked out that for a graphical interaction with the use, I would use SDL. I discovered that DJGPP was not compatible with SDL, and hence I moved to MinGW.
After reading a few pages of a C SDL tutorial, I decided that notepad wasn't going to be the most efficient way forward - I went with the suggested program, Code::Blocks.
This is where the problems began. Even after several uninstalls/reinstalls and following step-by-step instructions, I am apparently not doing it right.
This is my latest attempt:
I'm running Windows XP.
First, I uninstalled all of the previously mentioned programs and deleted any remaining folders/files.
I downloaded codeblocks-8.02mingw-setup.exe, and installed it. I ticked the box so that it would automatically install MinGW, detect it, and set it as default.
I downloaded SDL-devel-1.2.13-mingw32.tar.gz and extracted the archive into its own folder elsewhere on my system.
Then I followed the instructions given here following "the good" instructions and then continuing down through "The Process".
I'll be verbose - for each step given, I'll say exactly what I did...
(Steps 1 and 2 are already covered with sufficient detail)
--- Quote from: wiki ---Step 3: Copy SDL.dll from inside the bin folder to the your compilers bin directory (ie C:\Mingw\bin) This allows the compiler to find the dll at runtime time without having to put it in the same folder as your program or in the windows folder.
--- End quote ---
I copied sdl.dll into C:\Program Files\CodeBlocks\MinGW\bin
--- Quote from: wiki ---Step 4: Copy the contents of lib to your compiler's lib folder. If MinGW is installed under C:\MinGW, then this will be C:\MinGW\lib.
--- End quote ---
Much like step 2, I copied the contents of the lib file in my SDL archive (three files - two .a's and one .la) into C:\Program Files\CodeBlocks\MinGW\lib
Step 5... it goes on like this.
I decided to perform the optional Step 6 - placing SDL.dll into C:\Windows
I have not yet tried to follow the "Alternative" method (listed under "the good").
Here's a screenshot of the final file structure (relevant, I hope)
That covers "The Good", and I move onto the bottom section, "The Process".
Following the given instructions, I start a new project with the SDL template.
It then asks me to provide the location of SDL on my computer - this doesn't seem to be mentioned in the guide at all. However, the window states 'this folder must contain the subfolders "include" and "lib" ' So I went with C:\Program Files\CodeBlocks\MinGW - it meets the stated requirements and I believe I had copied the necessary files into its subfolders.
Then the error message pops up:
Now, I've seen no mention of this header file up until now, so I'm totally stumped.
I'm doing it wrong - but how do I fix it?
TDragon:
Unfortunately, the Code::Blocks SDL wizard hasn't been updated since SDL changed its include file layout. Not your fault. To get by this, temporarily copy SDL.h up a level (from "SDL" to "include"). This is just to get the wizard to finish; you should then get rid of the copy and adjust any #include <SDL.h> to #include <SDL/SDL.h>.
MortenMacFly:
--- Quote from: TDragon on December 02, 2008, 05:32:07 pm ---Unfortunately, the Code::Blocks SDL wizard hasn't been updated since SDL changed its include file layout.
--- End quote ---
Alternatively easily modify the wizard accordingly (and, if you like, provide us with a patch). To do so directly from the page where you choose the wizards: Right-Click on the SDL wizard and select "Edit" (or was it "Modify"... I don't remember exactly). This wizard is very tiny - you will easily find the position where the include path is defined.
JonMW:
--- Quote from: TDragon on December 02, 2008, 05:32:07 pm ---Unfortunately, the Code::Blocks SDL wizard hasn't been updated since SDL changed its include file layout. Not your fault. To get by this, temporarily copy SDL.h up a level (from "SDL" to "include"). This is just to get the wizard to finish; you should then get rid of the copy and adjust any #include <SDL.h> to #include <SDL/SDL.h>.
--- End quote ---
It worked! Incredible... I was so sure that I'd made some error somewhere.
Thanks to both of you!
stahta01:
--- Quote from: MortenMacFly on December 02, 2008, 08:49:34 pm ---Alternatively easily modify the wizard accordingly (and, if you like, provide us with a patch). To do so directly from the page where you choose the wizards: Right-Click on the SDL wizard and select "Edit" (or was it "Modify"... I don't remember exactly). This wizard is very tiny - you will easily find the position where the include path is defined.
--- End quote ---
Tested Patch using MinGW GCC; With the changes I think MSVC needs, it finally worked OK.
Should be tested on an Linux Machine.
Should be tested Using MSVC.
FYI: The VC8 dev file did NOT use the include "SDL/SDL.h" used just "SDL.h".
--- Code: ---Index: src/plugins/scriptedwizard/resources/sdl/files/main.cpp
===================================================================
--- src/plugins/scriptedwizard/resources/sdl/files/main.cpp (revision 5327)
+++ src/plugins/scriptedwizard/resources/sdl/files/main.cpp (working copy)
@@ -3,10 +3,10 @@
#else
#include <stdlib.h>
#endif
-#ifdef __APPLE__
-#include <SDL/SDL.h>
+#ifdef _MSC_VER
+ #include <SDL.h>
#else
-#include <SDL.h>
+ #include <SDL/SDL.h>
#endif
int main ( int argc, char** argv )
Index: src/plugins/scriptedwizard/resources/sdl/wizard.script
===================================================================
--- src/plugins/scriptedwizard/resources/sdl/wizard.script (revision 5327)
+++ src/plugins/scriptedwizard/resources/sdl/wizard.script (working copy)
@@ -47,8 +47,12 @@
local dir_nomacro_inc = GetCompilerIncludeDir(dir, SDLPathDefault, SDLPathDefaultInc);
if (dir_nomacro_inc.IsEmpty())
return false;
- if (!VerifyFile(dir_nomacro_inc, _T("SDL.h"), _T("SDL's include")))
+
+ local is_msvc = GetCompilerFactory().CompilerInheritsFrom(Wizard.GetCompilerID(), _T("msvc*"));
+ if (is_msvc && !VerifyFile(dir_nomacro_inc, _T("SDL.h"), _T("SDL's include")))
return false;
+ if (!is_msvc && !VerifyFile(dir_nomacro_inc, _T("SDL/SDL.h"), _T("SDL's include")))
+ return false;
// verify library dependencies
local dir_nomacro_lib = GetCompilerLibDir(dir, SDLPathDefault, SDLPathDefaultLib);
--- End code ---
Navigation
[0] Message Index
Go to full version