# C++ libtcod example doesn't work

I'm starting to learn C++ (I have a very basic programming background) and I have in mind to create an old-school ASCII-looking roguelike. I know it may be easier in Python, but it has to be in C++. I'm using Windows 10.

I want some eye candy beyond basic ASCII, I've seen libtcod 1.5.1 offers a lot of possibilities so I wanted to try it and follow this tutorial. The problem is I'm stuck right at the beginning, because the libtcod demo "samples_cpp.exe" works but not the example code:

#include "libtcod.hpp"

int main()
{
TCODConsole::initRoot(80, 50, "libtcod C++ tutorial", false);
while ( !TCODConsole::isWindowClosed() )
{
TCODSystem::checkForEvent(TCOD_EVENT_KEY_PRESS, NULL, NULL);
TCODConsole::root->clear();
TCODConsole::root->putChar(40, 25, '@');
TCODConsole::flush();
}

return 0;
}


If I launch the .exe compiled with the command:

g++ src/*.cpp -o tuto -Iinclude -Llib -ltcod-mingw -static-libgcc -static-libstdc++ -Wall


by double-click, it opens and closes a window very fast, and if I execute it from the console I get the in-console message:

24 bits font.
key color : 0 0 0
character for ascii code 255 is colored


Any clues of what I'm doing wrong? The project has all the proper .dll and include folder. This should be pretty easy :/

Thanks a million!

UPDATE: Ok, I got some new info, gdb says this:

[New Thread 7468.0x1f24]
24 bits font.
key color : 0 0 0
character for ascii code 255 is colored
Using SDL renderer...

Program received signal SIGSEGV, Segmentation fault.
0x65e70d9f in TCODConsole::clear (this=0x1) at src/console.cpp:196
196     src/console.cpp: No such file or directory.


Not sure what that means, the console.cpp file of libtcode at line 196 has the following:

void TCODConsole::clear() {
TCOD_console_clear(data);
}

• The command you listed isn't for launching the generated .exe, it's for compiling the code. – Pikalek Sep 21 '16 at 0:54
• I know, I mean I compiled the exe with that command. I'll edit to clarify. – JoePerkins Sep 21 '16 at 10:32
• Have you seen this thread? forums.roguetemple.com/index.php?topic=4239.0 – Tyyppi_77 Sep 21 '16 at 16:25
• I didn't! It seems to be the exact same problem, I'll see if it helps. Thanks! – JoePerkins Sep 21 '16 at 16:46