I have a consistent problem trying to launch SDL projects in code::blocks.
When asked to specify the folder in which I have placed SDL, I get the error: "The folder seems valid, but this wizard could not find the file SDL.h in it".
The file is in there, in a subfolder ("include"). Is this a problem with the wizard?
When I just try to open a simple console application and type my SDL code there, I get numerous error messages from MinGW, which I interpret as the library not being linked (e.g. "undefined reference to CreatePalette@4"), although i link to "libSDL.a; libSDL.dll.a; libSDLmain.a", and have listed both the include and lib folders as "search directories".
The specifics:
I am running a windows system. SDL has been installed from sources using MSYS in the folder "C:\MinGW\MSYS\local" (lib and include folders). I direct the SDL wizard to "C:\MinGW\MSYS\local"; "SDL.h" is found in "C:\MinGW\MSYS\local\include".
I have tried setting a global variable "sdl" to the appropriate targets.
Thanks for any help
Edit:
The problem persists.
I have now tried the precompiled version of SDL, and changed the directories. I have also copied all the header files from the include folder to the SDL top folder (so that SDL.h is directly in the folder that I direct C::B to). This does not seem like an SDL issue, maybe a bug in the wizard? Or have I forgot something? Can anyone give me a little help here?
The missing functions come from the Win32 api. Search for them on MSDN to find the appropriate link libraries to add -- for instance, CreatePalette is linked from gdi32.lib (in C::B, add "gdi32" to the Link Libraries list in your project's linker options). Most of them will actually be resolved with the catch-all "-mwindows" linker option, actually.
I do not have gdi32.lib. I have libgdi32.a, but linking to that, or using the -mwindows option does not solve the problem.
Am I to understand that the SDL project wizard is officially not working? Or is this a local problem on my machine?
libgdi32.a is the MinGW equivalent of MSVC's gdi32.lib; adding "gdi32" to the link options as I recommended causes C::B to append "-lgdi32" to the link-time options which will bring in libgd32.a.
At any rate, the SDL wizard is slightly broken; by temporarily copying SDL.h to the <SDL>\include folder, then restoring it and fixing the paths in the project search directories to point to <SDL>\include\SDL, everything worked fine:
mingw32-g++.exe -Wall -g -IG:\Libraries\SDL-1.2.12\include\SDL -IG:\MinGW\include -c G:\Projects\test\main.cpp -o obj\debug\main.o
mingw32-g++.exe -LG:\Libraries\SDL-1.2.12\lib -LG:\MinGW\lib -o debug\test.exe obj\debug\main.o -lmingw32 -lSDLmain -lSDL.dll -luser32 -lgdi32 -lwinmm -ldxguid
Output size is 368.63 KB
Process terminated with status 0 (0 minutes, 1 seconds)
0 errors, 0 warnings
(The above is from the Build log with full command-line logging enabled.)
Thanks!
Quote from: mkborregaard on November 08, 2007, 08:38:54 PM
I have a consistent problem trying to launch SDL projects in code::blocks.
When asked to specify the folder in which I have placed SDL, I get the error: "The folder seems valid, but this wizard could not find the file SDL.h in it".
The file is in there, in a subfolder ("include"). Is this a problem with the wizard?
CB Checks the include directory inside the specified SDL base directory (or root), but if you do as i did and unzip the SDL files as theyr are packaged, they will be placed in SDL_root\include\SDL, CB doesn't recognise them there. I copied them out to SDL_root\include and SDL templates and projects seem to run fine.
EDIT: Just read the better solution 2 posts up :P
We are in March 2010 and the bug is still there in the SDL wizard : The first time I launched the wizard, a panel opened asking me to specify the search directories for SDL lib. I thought if I leave them empty it will select the default settings. These default setting are probably wrong and now this extra panel never shows up again.
I had to duplicate the header files both in include/. and include/sdl/. to fix the problem and keep my former projects working.
It's not a big deal but all theses bugs in CB Wizards always discouraged me from using CodeBlocks despite I'm glad this tool exists.
The patch I used about 6 to 12 months ago; feel free to submit to BerliOS with your name on it; I do not have the time and energy to test & maintain patches.
Note, It needs tested to verify it still works and was never tested on Linux.
Tim S.
Index: src/plugins/scriptedwizard/resources/sdl/wizard.script
===================================================================
--- src/plugins/scriptedwizard/resources/sdl/wizard.script (revision 5680)
+++ src/plugins/scriptedwizard/resources/sdl/wizard.script (working copy)
@@ -47,8 +47,15 @@
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")))
- return false;
+
+ if (!IO.FileExists(dir_nomacro_inc + wxFILE_SEP_PATH + _T("SDL.h")))
+ {
+ if (VerifyFile(dir_nomacro_inc, _T("SDL/SDL.h"), _T("SDL's include")))
+ SDLPathDefaultInc = SDLPathDefaultInc + _T("/SDL");
+ else
+ return false;
+ }
+
// verify library dependencies
local dir_nomacro_lib = GetCompilerLibDir(dir, SDLPathDefault, SDLPathDefaultLib);