SIGSEGV when using libtcod (TCODConsole::root->...)

Hi! I'm a beginner with C++ and have started with this Roguelike tutorial: http://codeumbra.eu/series/complete-roguelike-tutorial-using-c-and-libtcod
I'm using Code::Blocks 13.12 with the built-in MinGW compiler.

When running the code I has written following part 1 of the tutorial, I noticed the application window closed directly after opening. Running the program using the debugger, I see there's a segmentation fault, signaled at line 20 (and, if you comment it out, also 21).
So what's not working is TCODConsole::root->clear(); and TCODConsole:root->putChar();.
Here's the full code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include "libtcod.hpp"

int main()
{
    int playerx = 40, playery = 25;
    TCODConsole::initRoot(10,10, "The Roguelike of the Nallebjörn",false);
    while (!TCODConsole::isWindowClosed())
    {
        TCOD_key_t key;
        TCODSystem::checkForEvent(TCOD_EVENT_KEY_PRESS, &key, NULL);
        switch (key.vk)
        {
            case TCODK_UP: playery--; break;
            case TCODK_DOWN: playery++; break;
            case TCODK_LEFT: playerx--; break;
            case TCODK_RIGHT: playerx++; break;
            default:break;
        }

        TCODConsole::root->clear();
        TCODConsole::root->putChar(playerx,playery, '@');
        TCODConsole::flush();
    }
    return 0;
}


So what's wrong? Seems very much like something's wrong with the root pointer to me... If you need more info (got a feeling you do, but not sure about what you have to know), tell me and I'll be happy to help you help me :)
OK... I managed to solve this as suggested here:
http://doryen.eptalys.net/forum/index.php?topic=1573.msg8905

I had tried replacing my libtcod with the one in reply #6 without luck earlier... However, I forgot replacing the libtcod DLL files with with new ones.

If anyone could explain why the linked version (compiled with GCC 4.7) works, but not the standard one, downloaded from the official website, I'd bee very happy, though.
Topic archived. No new replies allowed.