Sign in to follow this  

SDL wrapper problem

Recommended Posts

Hi, everyone! this is my first post ever at

I've known this page for some time now but never actually registered.
Now i have a big doubt about writing a C++ wrapper for SDL.

I wrote this code as a test:

#include <iostream>
#include <SDL/SDL.h>

using namespace std;

class Proto {
virtual ~Proto(){

static int initialize(){
int result = SDL_Init(SDL_INIT_VIDEO);
return result;

int main(int argc, char* argv[]) {


cout << "SDL Initialized!!!" << endl;
return 0;

However, when i debug and step into Proto::initialize,
the program just freezes in SDL_Init.

If i call SDL_Init directly from the main() function
there's no problem. But if i encapsulate it in another class
whether in a static function or non-static member function,
it doesn't work.

If i continue execution, it never ends. I have to terminate it.

If i just execute the resulting binary(not debug) it starts
and ends without error message from console.

The message is never printed on screen.

What is going on? I'm doing this in eclipse on windows and mingw32.

Share this post

Link to post
Share on other sites
Hi, storyyeller. Thanks for your answer. That's something new to me. Singleton and lazy initialization. Not sure how one implements that, though i read this
(C++ example part).

However, i took my code in a linux VM and guess what? No problems with Linux GCC.
I also compiled my code under Visual C++ 2010 Express, and no problems either.

So i'm starting to think theres something wrong with my Mingw32 config, or with the compiler itself.

What do you think?

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this