News:

Accounts with zero posts and zero activity during the last months will be deleted periodically to fight SPAM!

Main Menu

Bug in SDL project wizard?

Started by mkborregaard, November 08, 2007, 08:38:54 PM

Previous topic - Next topic

mkborregaard

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?

TDragon

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.
[url="https://jmeubank.github.io/tdm-gcc/"]https://jmeubank.github.io/tdm-gcc/[/url] - TDM-GCC compiler suite for Windows (GCC 9.2.0 2020-03-08, 32/64-bit, no extra DLLs)

mkborregaard

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?

TDragon

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.)
[url="https://jmeubank.github.io/tdm-gcc/"]https://jmeubank.github.io/tdm-gcc/[/url] - TDM-GCC compiler suite for Windows (GCC 9.2.0 2020-03-08, 32/64-bit, no extra DLLs)

mkborregaard


Barking_Mad

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
WooF! WooF! - Ubuntu 8.10 & CB 5432 & GCC 4.3.2
To see the world in a grain of sand and heaven in a wild flower
To hold infinity in the palm of your hand and eternity in an hour - W.B

Derdonn

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.

stahta01

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);
C Programmer working to learn more about C++.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. [url="http://wiki.codeblocks.org"]http://wiki.codeblocks.org[/url]