Compiling tome 2 in Windows

Everything about ToME 2.x.x. No spoilers, please

Moderator: Moderator

Post Reply
Message
Author
Harmless
Cornac
Posts: 34
Joined: Sun Aug 16, 2009 4:40 pm

Compiling tome 2 in Windows

#1 Post by Harmless »

All credit goes to Reaten for this list, he doesn't even play the game but still put in the work to get this to compile.

How to build Tome2.exe in Windows 7
------------------------------------

install mingw-get-setup.exe from http://sourceforge.net/projects/mingw/f ... urce=files to C:\MinGW
run the setup.exe
in InstallationManager
mark mingw32-base and mingw32-gcc-g++ for installation
From Installation menu at the top, choose Apply Changes
Click Apply

add C:\MinGW\bin\ to system path

download http://ftp.gnome.org/pub/gnome/binaries ... _win32.zip
extract \bin\pkg-config.exe to C:\MinGW\bin

download http://ftp.gnome.org/pub/gnome/binaries ... _win32.zip
extract 7 files from \bin into C:\MinGW\bin

download http://ftp.gnome.org/pub/gnome/binaries ... _win32.zip
extract \bin\intl.dll from \bin into C:\MinGW\bin

download http://www.cmake.org/files/v2.8/cmake-2 ... 32-x86.zip
extract \bin files to C:\Program Files (x86)\CMake
add C:\Program Files (x86)\CMake\bin to system path

reboot to make sure system path changes take (optional)

download https://github.com/akheron/jansson/archive/master.zip
extract zip into C:\MinGW\jansson-master

edit file C:\MinGW\jansson-master\CMakeLists.txt, comment out line 116 by changing to:
#add_definitions("-fPIC")

open CMake gui (in the Start Menu)

Click "Browse Source..." and set it to C:\MinGW\jansson-master.

Click "Browse Build..." and set it to C:\MinGW\jansson-master\build (make a new folder).

Click "Configure", click yes to make directory if it asks

Choose "MinGW Makefiles" and "Use default native compilers" and click Finish. Ignore the "Sphinx not found" warning.

In the middle area (red background where you edit variables with Name and Value columns)
Uncheck JANSSON_BUILD_DOCS
change CMAKE_INSTALL_PREFIX to C:\MinGW\jansson-master\install (make a new folder).
go to windows explorer and make the C:\MinGW\jansson-master\install folder

Click "Configure" again, then click "Generate" and close CMake.

Open the command prompt (cmd.exe) and type the following to compile Jansson:
cd C:\MinGW\jansson-master\build
mingw32-make install

edit the file C:\MinGW\jansson-master\install\lib\pkgconfig\jansson.pc line 3, change to:
libdir=C:\MinGW\jansson-master\install/C:\\MinGW\\jansson-master\\install/lib

copy all files from C:\MinGW\jansson-master\install\lib into C:\MinGW\lib
copy all files from C:\MinGW\jansson-master\install\include into C:\MinGW\include

install git for windows from http://git-scm.com/download/win

clone https://gitlab.com/tome2/tome2.git to a new directory

1. Right click somewhere in windows explorer and choose Git Gui

2. Choose Clone existing repository

3. Source location = https://gitlab.com/tome2/tome2.git
(or mirror at https://gitorious.org/tome2/tome2.git)
Target directory = c:\tome2


edit two tome2\src files that don't work

- c:\tome2\src\config.h
- scroll down till you see the "where to put the user's files"-section, line 160, change to:

#if defined(MACH_O_CARBON)
#define PRIVATE_USER_PATH "~/Library/Application Support/ToME"
#define PRIVATE_USER_PATH_DATA
#define PRIVATE_USER_PATH_MODULES
#elif defined(WIN32)
#define PRIVATE_USER_PATH "."
#else
#define PRIVATE_USER_PATH "~/.tome"
#endif

- c:\tome2\src\modules.c
- add the following snippet right after the line saying: #include "angband.h", line 14

#include <sys/stat.h>
bool_ private_check_user_directory(cptr dirpath)
{
struct stat stat_buf;
int ret;
ret = stat(dirpath, &stat_buf);
if (ret == 0)
{
if ((stat_buf.st_mode & S_IFMT) == S_IFDIR) return (TRUE);
return (FALSE);
}
else
{
ret = mkdir(dirpath);
if (ret == -1) return (FALSE);
return (TRUE);
}
}

Open cmake gui from start menu

Where is the source code = c:\tome2
Where to build the binaries = c:\tome2\build

Click Configure
Click Finish

Change CMAKE_INSTALL_PREFIX to c:\tome2\install
in windows explorer create the c:\tome2\install directory

Click Configure again

Click Generate

go to command prompt in target directory and run mingw32 make install
run cmd.exe
cd c:\tome2\build
mingw32-make install

copy c:\Tome2\tome.ini to c:\Tome2\install\bin\
copy c:\Tome2\lib folder into c:\Tome2\install\bin\
create a directory C:\Tome2\install\bin\2.4
create a directory C:\Tome2\install\bin\2.4\save

Run C:\Tome2\install\bin\tome.exe

It's just that easy!!!

ASSUMES:

version 2.3.x of Tome2
version 2.7 of Jansson

REFERENCES:

http://stackoverflow.com/questions/1710 ... in-windows
https://github.com/ictxiangxin/LoongHac ... d-mingw.md
http://stackoverflow.com/questions/1305 ... e-compiler
http://forums.te4.org/viewtopic.php?f=1 ... &start=195

Thanks again Reaten, and Anonymous Hero for a few tips as well. Hopefully someone else finds this useful and ends up enjoying the game as much as I have over the years.

AnonymousHero
Spiderkin
Posts: 482
Joined: Sat Mar 18, 2006 12:48 pm

Re: Compiling tome 2 in Windows

#2 Post by AnonymousHero »

Wow, really sad that 3rd part dependencies are such a pain on Windows... I guess I should look for a header-only JSON implementation in C++ and use that instead. I'll put that on my TODO-list. (As usual no guarantees about when I might get to it, though!)

EDIT: Btw, could you perhaps post diffs of what you've changed in the T2 source? I'd like to incorporate everything I can upstream.

Post Reply