Visual Studio 2015 + libtcod - Unexpected exit

428 Views Asked by At

I am having an odd issue getting libtcod to work with Visual Studio 2015.

I have followed all the steps found on this blog post to get everything linked.

The problem is that during debugging or running it inside Visual Studio the application will always close at initRoot with exit code 1, no other information or errors.

Running the produced EXE outside of Visual Studio has no issues whatsoever - starts up and works as expected!

The only information I could find related to this was a forum post that turned ugly in 2012

I did make a modification to the blog post's code to include a setCustomFont as well, which did not change anything.

Does anyone have any ideas on what might be going on?

Code:

#include <cstdio>
#include "libtcod.hpp"

// Hide the console window
#pragma comment(linker, "/SUBSYSTEM:windows /ENTRY:mainCRTStartup")

int main()
{
    TCODConsole::setCustomFont("terminal12x12_gs_ro.png", TCOD_FONT_LAYOUT_ASCII_INROW | TCOD_FONT_TYPE_GRAYSCALE);
    TCODConsole::initRoot(80, 50, "C++ libtcod tutorial");
    TCODConsole::root->printEx(40, 25, TCOD_BKGND_NONE, TCOD_CENTER, "Hello world");
    TCODConsole::flush();
    TCODConsole::waitForKeypress(true);

    return 0;
}
1

There are 1 best solutions below

0
On BEST ANSWER

For anyone that stumbles upon this later, the above blog post is correct for setting up the vast majority of the application - if you run into the same issue I did (crashing / exiting in initRoot) make sure you have the terminal png in the source directory, this is what fixed it for me.