So awhile back, I mentioned I had an idea for a roguelike. (
http://forums.roguetemple.com/index.php?topic=4477.0) Now I've finally gotten around to trying to learn libtcod, and... hoo boy.
I haven't done c++ coding in awhile and I don't know python, so I go to jice's c++ tutorial (
http://codeumbra.eu/complete-roguelike-tutorial-using-c-and-libtcod-part-1-setting-up).
I install orwell dev-c++, but getting it to work is a pain and even when pointed at the library what seems to be properly, it won't compile. I decide to use a more direct toolchain.
I install MinGW (the latest 32-bit version, of course) and compile the 'test if things are installed' program from the first tutorial chapter.
Of course, MinGW turns out to be bugged (
http://sourceforge.net/p/mingw/bugs/2108/), but this just means having to click a button a few times every time I compile something. Okay, I can deal.
The program doesn't open a window or anything. But hey, jice explains how to debug c++ programs!
gdb reveals that my program is segfaulting because of some problem with the library.
Jice doesn't explain how to use the debug libraries, but I can figure it out. Now, recompile and have a look...
J:\dev\proto>gdb tuto
GNU gdb (GDB) 7.6.1
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "mingw32".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from J:\dev\proto\tuto.exe...done.
(gdb) run
Starting program: J:\dev\proto/tuto.exe
[New Thread 14144.0x2964]
[New Thread 14144.0x1098]
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.
(gdb) bt
#0 0x65e70d9f in TCODConsole::clear (this=0x1) at src/console.cpp:196
#1 0x0040149b in main () at src/main.cpp:15
(gdb) q
A debugging session is active.
Inferior 1 [process 14144] will be killed.
Quit anyway? (y or n) y
error return ../../gdb-7.6.1/gdb/windows-nat.c:1275 was 5
A search of the internet reveals that this happens to a lot of people, and seems to be the result of my MinGW version not being an exact match for the one the library was compiled on, which makes me wonder why binaries of the library are being distributed at all.
J:\dev\proto>g++ -dumpversion
4.8.1
Okay. Since I have the latest MinGW version, I'll just grab the latest, nightly build of libtcod 1.5.2
No dice, same error.
Okay. so I need to build the library myself. fine. There are instructions: (
http://roguecentral.org/doryen/data/libtcod/doc/1.5.2/html2/compile_libtcod_mingw.html?c=true&cpp=true&cs=true&py=true&lua=true)
'which' doesn't do anything, which is hardly a surprise at this point, but I can just run hg from the windows command line.
Finally, once I have the source for libtcod, I get into a MingW shell, go to the directory, and make it as instructed.
The MinGW error box pops up twice for every .c or .cpp file, but I'll endure.
$ make -f makefiles/makefile-mingw
Compiling debug src/bresenham_c.c
Compiling debug src/bsp_c.c
Compiling debug src/color_c.c
Compiling debug src/console_c.c
Compiling debug src/fov_c.c
Compiling debug src/fov_circular_raycasting.c
Compiling debug src/fov_diamond_raycasting.c
Compiling debug src/fov_recursive_shadowcasting.c
Compiling debug src/fov_permissive2.c
Compiling debug src/fov_restrictive.c
Compiling debug src/heightmap_c.c
Compiling debug src/image_c.c
Compiling debug src/lex_c.c
Compiling debug src/list_c.c
Compiling debug src/mersenne_c.c
Compiling debug src/noise_c.c
Compiling debug src/parser_c.c
Compiling debug src/path_c.c
Compiling debug src/sys_c.c
Compiling debug src/sys_sdl_c.c
Compiling debug src/sys_sdl12_c.c
Compiling debug src/sys_sdl_img_bmp.c
Compiling debug src/sys_sdl_img_png.c
Compiling debug src/tree_c.c
Compiling debug src/txtfield_c.c
Compiling debug src/wrappers.c
Compiling debug src/zip_c.c
Compiling debug src/namegen_c.c
Compiling debug src/bresenham.cpp
Compiling debug src/bsp.cpp
Compiling debug src/color.cpp
Compiling debug src/console.cpp
Compiling debug src/fov.cpp
Compiling debug src/heightmap.cpp
Compiling debug src/image.cpp
Compiling debug src/lex.cpp
Compiling debug src/mersenne.cpp
Compiling debug src/mouse.cpp
Compiling debug src/noise.cpp
Compiling debug src/parser.cpp
Compiling debug src/path.cpp
Compiling debug src/sys.cpp
Compiling debug src/sys_opengl_c.c
Compiling debug src/txtfield.cpp
Compiling debug src/zip.cpp
Compiling debug src/namegen.cpp
Compiling debug src/png/lodepng.c
Compiling zlib src/zlib/adler32.c
Compiling zlib src/zlib/crc32.c
Compiling zlib src/zlib/deflate.c
Compiling zlib src/zlib/infback.c
Compiling zlib src/zlib/inffast.c
Compiling zlib src/zlib/inflate.c
Compiling zlib src/zlib/inftrees.c
Compiling zlib src/zlib/trees.c
Compiling zlib src/zlib/zutil.c
Compiling zlib src/zlib/compress.c
Compiling zlib src/zlib/uncompr.c
Compiling zlib src/zlib/gzclose.c
Compiling zlib src/zlib/gzlib.c
Compiling zlib src/zlib/gzread.c
Compiling zlib src/zlib/gzwrite.c
c:\MinGW\bin\ar.exe: creating lib/libz.a
Linking libtcod-mingw-debug.dll
Compiling debug src/gui/button.cpp
Compiling debug src/gui/container.cpp
Compiling debug src/gui/flatlist.cpp
Compiling debug src/gui/hbox.cpp
Compiling debug src/gui/image.cpp
Compiling debug src/gui/label.cpp
Compiling debug src/gui/radiobutton.cpp
Compiling debug src/gui/slider.cpp
Compiling debug src/gui/statusbar.cpp
Compiling debug src/gui/textbox.cpp
Compiling debug src/gui/togglebutton.cpp
Compiling debug src/gui/toolbar.cpp
Compiling debug src/gui/vbox.cpp
Compiling debug src/gui/widget.cpp
Linking libtcod-gui-mingw-debug.dll
Compiling release src/bresenham_c.c
Compiling release src/bsp_c.c
Compiling release src/color_c.c
Compiling release src/console_c.c
Compiling release src/fov_c.c
Compiling release src/fov_circular_raycasting.c
Compiling release src/fov_diamond_raycasting.c
Compiling release src/fov_recursive_shadowcasting.c
Compiling release src/fov_permissive2.c
Compiling release src/fov_restrictive.c
Compiling release src/heightmap_c.c
Compiling release src/image_c.c
Compiling release src/lex_c.c
Compiling release src/list_c.c
Compiling release src/mersenne_c.c
Compiling release src/noise_c.c
Compiling release src/parser_c.c
Compiling release src/path_c.c
Compiling release src/sys_c.c
Compiling release src/sys_sdl_c.c
Compiling release src/sys_sdl12_c.c
Compiling release src/sys_sdl_img_bmp.c
Compiling release src/sys_sdl_img_png.c
Compiling release src/tree_c.c
Compiling release src/txtfield_c.c
Compiling release src/wrappers.c
Compiling release src/zip_c.c
Compiling release src/namegen_c.c
Compiling release src/bresenham.cpp
Compiling release src/bsp.cpp
Compiling release src/color.cpp
Compiling release src/console.cpp
Compiling release src/fov.cpp
Compiling release src/heightmap.cpp
In file included from src/heightmap.cpp:27:0:
c:\mingw\include\math.h: In function 'float hypotf(float, float)':
c:\mingw\include\math.h:635:30: error: '_hypot' was not declared in this scope
{ return (float)(_hypot (x, y)); }
^
make: *** [/tmp/libtcod/release/heightmap.o] Error 1
WELL F***.
So, as far as I can tell, trying to use libtcod from publicly available information is simply a no-go. This toolchain is f*cked and I cannot believe anyone actually uses it this way -- I must be doing something
very wrong.
So, how do I
actually use libtcod? Or does noone use it anymore and I need to find something else?