SDL Woopsi is Go

More mucking about with Xcode. I ran into a problem where it insisted that “_SDL_main” was an undefined symbol. After scouting the net for a while and not finding anything particularly enlightening about the problem, I created a new SDL project and tried to compile it - no problems. Gradually copied sections of Woopsi from the old project into the new one, compiling every time - no problems. Rebuilt the main.cpp file piece by piece - no problems.

So what was causing the problem? No idea.

The colours are now correctly shifted from 16-bit to 32-bit, and the cursor keys are wired up. Aside from the bizarre and unpredictable behaviour of Xcode, the only real problem I ran into was with the glyphs. Turns out that I should really indicate in my code that I want unsigned chars, as not every platform implements them in the same way. The Mac defaults to signed chars, which meant that the glyphs (being above the 127 max value of a signed char in the font character array) didn’t get drawn. Fixing it was just a question of toggling a checkbox in the project’s properties. Even I can manage that one.

Here’s Woopsi, compiled for the Mac. Requires SDL. I think I’ve compiled it for PPC and Intel architectures.

WoopsiSDL for Mac

Here’s a screengrab:


Coding with SDL has been completely painless (aside from the missing symbol thing). I used it very briefly to write a quick version of Pong for the GP32, but haven’t used it aside from that. I can see why so many open source projects use it - cross platform and easy to use.


Dunk on 2007-12-24 at 21:09 said:

”…So what was causing the problem? No idea.”


Jeff on 2007-12-25 at 01:05 said:

I would guess that you had the library included in your project, but not enabled in your target. Thus, the library appears to be part of the overall work, but is not specifically linked.

On the other hand, I would expect a lot more undefined symbols to come out - if that were the case, then as I recall, there was some #define hackery that SDL used, wasn’t there, that tried to replace your real main() with its own - that would have problems if you didn’t #include the sdl.h files in your real main.cpp file.

ie, they did

#define main SDL_main

which would transform your main.cpp into containing an SDL_main() that the main() thats in the SDL library could call.

All just a guess, I haven’t looked at SDL for years, but it fits the symptoms you are reporting…