ToME 2 maintenance

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

Moderator: Moderator

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

Re: ToME 2 maintenance

#16 Post by AnonymousHero »

That's a shame. Budswell, could you please try compiling by including the pstdint.h found here:

http://code.google.com/p/baseutils/sour ... /pstdint.h

instead of <stdint.h>? If it works, I'll include and use that instead (it automatically falls back to stdint.h where it's available).

Btw, my goal is to have the CMake build system also support building on Windows, so I basically just need someone to help figure out which compiler switches and such are needed on the VS compiler and CMake should be able to figure out the rest once I tell if to include the main-win.c frontend.

EDIT: Shame about stdint.h, I mean. :)

Kernigh
Wayist
Posts: 23
Joined: Sun Jan 31, 2010 3:55 pm

Re: ToME 2 maintenance

#17 Post by Kernigh »

Code: Select all

$ make
Scanning dependencies of target lua
[  0%] Building C object src/lua/CMakeFiles/lua.dir/lapi.c.o
[  1%] Building C object src/lua/CMakeFiles/lua.dir/lcode.c.o
...
[ 35%] Generating w_quest.c
[ 36%] Generating w_dun.c
Scanning dependencies of target tome
[ 37%] Building C object src/CMakeFiles/tome.dir/main-gcu.c.o
[ 38%] Building C object src/CMakeFiles/tome.dir/main-x11.c.o
/home/kernigh/park/tome2-tome2/src/main-x11.c:100:22: X11/Xlib.h: No such file or directory
/home/kernigh/park/tome2-tome2/src/main-x11.c:101:23: X11/Xutil.h: No such file or directory
/home/kernigh/park/tome2-tome2/src/main-x11.c:102:24: X11/keysym.h: No such file or directory
/home/kernigh/park/tome2-tome2/src/main-x11.c:103:27: X11/keysymdef.h: No such file or directory
/home/kernigh/park/tome2-tome2/src/main-x11.c:104:23: X11/Xatom.h: No such file or directory
...
/home/kernigh/park/tome2-tome2/src/main-x11.c:3277: error: `ZPixmap' undeclared (first use in this function)
*** Error code 1

Stop in /home/kernigh/park/tome2-tome2/work (line 78 of src/CMakeFiles/tome.dir/build.make).
*** Error code 1

Stop in /home/kernigh/park/tome2-tome2/work (line 79 of CMakeFiles/Makefile2).
*** Error code 1

Stop in /home/kernigh/park/tome2-tome2/work (line 113 of Makefile).
$
This is a day in the life of Kernigh, an OpenBSD user. I try to build ToME, but fail with the above error message, because something forgot to find my X11 header files in /usr/X11R6/include. (OpenBSD clings to an old custom, and thus has X11R7 in /usr/X11R6.)

I have not played ToME for two years. Agrelaa the High-Elf Loremaster was my last character. Agrelaa survived level 35 of the Helcaraxe, when I stopped playing at January 2008. I lost my save file and my ToME executable. I want to start a new character, so I must build another ToME executable.

I came at http://gitorious.org/tome2/tome2, but I had no way to clone the repository. (I have Cvs, Subversion and Mercurial but not Git.) I wanted to download a snapshot of the source code. I clicked "Source tree", then "Download master as tar.gz". I extracted my snapshot from 31 January 2010 into a directory named tome2-tome2, and started an out-of-source build.

Code: Select all

$ cd tome2-tome2
$ mkdir work
$ cd work
$ cmake ..
...
$ make
So I have this error, because something forgot to find my X11 header files in /usr/X11R6/include. I am lucky that this is a CMake project. I know CMake (since the year 2007), so I might fix the listfile.

The top-level CMakeLists.txt invokes FIND_PACKAGE(X11) and then INCLUDE_DIRECTORIES(${X11_INCLUDE_DIRS}). This is a typo, because cmake --help-module FindX11 says to use X11_INCLUDE_DIR (without the S).

I fix the typo, reconfigure and restart the build.

Code: Select all

[ 39%] Building C object src/CMakeFiles/tome.dir/main-sdl.c.o
In file included from /usr/local/include/SDL/SDL_main.h:26,
                 from /usr/local/include/SDL/SDL.h:28,
                 from /home/kernigh/park/tome2-tome2/src/main-sdl.c:29:
/usr/local/include/SDL/SDL_stdinc.h:72:20: iconv.h: No such file or directory
/home/kernigh/park/tome2-tome2/src/main-sdl.c:31:21: SDL_ttf.h: No such file or directory
...
Stop in /home/kernigh/park/tome2-tome2/work (line 113 of Makefile).
This new error happens because the listfile enables the SDL interface of ToME, though I have no SDL_ttf library. The listfile now uses FIND_PACKAGE(SDL_ttf REQUIRED), but the FindSDL_ttf.cmake module (that comes with CMake 2.8.0) ignores the REQUIRED clause. If the module fails to find the library, then nothing happens.

I would install SDL_ttf, but I prefer to teach the listfile to disable the SDL interface if there is no SDL_ttf. I edit the top-level CMakeLists.txt, and reconfigure.

Code: Select all

$ cmake .
-- Found SDL and SDL_image, but not SDL_ttf!
-- Enabled features:
X11
Threads
SDL , not enabled
Curses

-- Configuring done
-- Generating done
-- Build files have been written to: /home/kernigh/park/tome2-tome2/work
There is no way to remove SDL from the list under "Enabled features". My workaround is to put a "not enabled" note. I can now do almost an entire build.

Code: Select all

[ 28%] Generating w_mnster.c
...
[ 92%] Generating w_mnster.c
[ 92%] Building C object src/CMakeFiles/tome.dir/w_mnster.c.o
gcc: /home/kernigh/park/tome2-tome2/work/src/w_mnster.c: No such file or directory
gcc: no input files
*** Error code 1
The build fails after twice generating w_msnter.c, yet failing to find the generated file. This is a familiar problem with custom rules and out-of-source builds. The custom rule wants to put w_mnster.c in the object directory, but the tolua command puts w_mnster.c in the source directory.

I edit src/CMakeLists.txt until I have a rule that seems to work.

Code: Select all

Linking C executable tome
...
ld: warning: libICE.so.9.0, needed by /usr/X11R6/lib/libSM.so.8.0, not found (try using -rpath or -rpath-link)
ld: warning: libXau.so.9.0, needed by /usr/X11R6/lib/libX11.so.11.2, not found (try using -rpath or -rpath-link)
ld: warning: libXdmcp.so.9.0, needed by /usr/X11R6/lib/libX11.so.11.2, not found (try using -rpath or -rpath-link)
ld: warning: libX11.so.11.2, needed by /usr/X11R6/lib/libXext.so.10.0, not found (try using -rpath or -rpath-link)
/usr/X11R6/lib/libX11.so.11.2: undefined reference to `XdmcpWrap'
/usr/X11R6/lib/libX11.so.11.2: undefined reference to `XauGetBestAuthByAddr'
/usr/X11R6/lib/libX11.so.11.2: undefined reference to `XauDisposeAuth'
*** Error code 1
This only means that FindX11.cmake (which comes with CMake 2.8.0) is not compatible with my OpenBSD system. For now, my workaround is to insert an -L/usr/X11R6/lib in the command line. I edit to CMakeCache.txt, changing

Code: Select all

//Path to a library.
X11_SM_LIB:FILEPATH=/usr/X11R6/lib/libSM.so.8.0
to

Code: Select all

//Path to a library.
X11_SM_LIB:FILEPATH=-L/usr/X11R6/lib;/usr/X11R6/lib/libSM.so.8.0
which is a temporary fix for the moment. I reconfigure and rebuild.

Code: Select all

[100%] Built target tome
$
I now have an actual tome executable, so I try to run it.

Code: Select all

$ cd ..
$ work/src/tome
The window appears, then disappears. I try work/src/tome -mgcu, but the program appears, draws the title screen, then disappears. My ToME executable always exits (with status 0) soon after start.

Code: Select all

$ gdb work/src/tome
GNU gdb 6.3
...
(gdb) run
...
Program received signal SIGSEGV, Segmentation fault.
0x01a4ee80 in lua_tonumber ()
(gdb) continue 
Continuing.

Program exited normally.
(gdb)
gdb reveals that ToME segfaults. The ToME crash handler disguises the segfault as a normal exit, but gdb reveals the signal.

This segfault seems too familiar. More than four years ago, at 29 May 2006, I wrote BugReport615 on the wiki. I now read my own bug report, and wonder if the same fix would work now.

I edit src/lua/lapi.c, by my own instructions in the bug report four years ago, and rebuild.

The game seems to work now. "Art thou an adventurer, One who passes through the waterfalls we call danger to find the true nature of the legends beyond them? If this is so, then seeketh me."

I defer the creation of a character until later, after I will review some spoilers.

Here follows the diff of my changes.

Code: Select all

--- CMakeLists.txt.orig	Mon Jan 18 16:13:46 2010
+++ CMakeLists.txt	Sun Jan 31 18:40:07 2010
@@ -27,7 +27,7 @@
 IF(X11_FOUND)
   # Add X11 flags/options
   ADD_DEFINITIONS(-DUSE_X11)
-  INCLUDE_DIRECTORIES(${X11_INCLUDE_DIRS})
+  INCLUDE_DIRECTORIES(${X11_INCLUDE_DIR})
   SET(LIBS ${LIBS} ${X11_LIBRARIES})
 ENDIF()
 
@@ -36,21 +36,27 @@
 #
 FIND_PACKAGE(SDL)
 IF(SDL_FOUND)
-  # Add SDL flags/options
-  ADD_DEFINITIONS(-DUSE_SDL)
-  INCLUDE_DIRECTORIES(${SDL_INCLUDE_DIR})
-  SET(LIBS ${LIBS} ${SDL_LIBRARY})
-  # SDL_image is also required
-  FIND_PACKAGE(SDL_image REQUIRED)
-  IF(SDLIMAGE_FOUND)
-    INCLUDE_DIRECTORIES(${SDLIMAGE_INCLUDE_DIR})
-    SET(LIBS ${LIBS} ${SDLIMAGE_LIBRARY})
-  ENDIF()
-  # SDL_ttf is also required
-  FIND_PACKAGE(SDL_ttf REQUIRED)
-  IF(SDLTTF_FOUND)
-    INCLUDE_DIRECTORIES(${SDLTTF_INCLUDE_DIR})
-    SET(LIBS ${LIBS} ${SDLTTF_LIBRARY})
+  # the SDL port also requires SDL_image and SDL_ttf
+  FIND_PACKAGE(SDL_image)
+  FIND_PACKAGE(SDL_ttf)
+  IF(SDLIMAGE_FOUND AND SDL_TTF_FOUND)
+    # Add SDL flags/options
+    ADD_DEFINITIONS(-DUSE_SDL)
+    INCLUDE_DIRECTORIES(${SDL_INCLUDE_DIR}
+      ${SDLIMAGE_INCLUDE_DIR} ${SDLTTF_INCLUDE_DIR})
+    SET(LIBS ${LIBS}
+      ${SDLIMAGE_LIBRARY} ${SDLTTF_LIBRARY} ${SDL_LIBRARY})
+  ELSE()
+    # proceed without enabling the SDL port
+    IF(SDLIMAGE_FOUND)
+      MESSAGE(STATUS "Found SDL and SDL_image, but not SDL_ttf!")
+    ELSEIF(SDLTTF_FOUND)
+      MESSAGE(STATUS "Found SDL and SDL_ttf, but not SDL_image!")
+    ELSE()
+      MESSAGE(STATUS "Found SDL, but not SDL_image nor SDL_ttf!")
+    ENDIF()
+    # add info about finding but not enabling SDL
+    SET_FEATURE_INFO(SDL "not enabled")
   ENDIF()
 ENDIF()
 
--- src/CMakeLists.txt.orig	Mon Jan 18 16:13:46 2010
+++ src/CMakeLists.txt	Sun Jan 31 19:57:03 2010
@@ -5,7 +5,9 @@
 MACRO(TOLUA_FILE MODULE_NAME OUTPUT_FILE_NAME)
   ADD_CUSTOM_COMMAND(
     OUTPUT ${OUTPUT_FILE_NAME}
-    COMMAND tolua -n ${MODULE_NAME} -o ${CMAKE_CURRENT_SOURCE_DIR}/${OUTPUT_FILE_NAME} ${CMAKE_CURRENT_SOURCE_DIR}/${MODULE_NAME}.pkg
+    COMMAND tolua -n ${MODULE_NAME}
+      -o ${CMAKE_CURRENT_BINARY_DIR}/${OUTPUT_FILE_NAME}
+      ${CMAKE_CURRENT_SOURCE_DIR}/${MODULE_NAME}.pkg
     DEPENDS tolua ${CMAKE_CURRENT_SOURCE_DIR}/${MODULE_NAME}.pkg
     )
   SET_SOURCE_FILES_PROPERTIES("${OUTPUT_FILE_NAME}" PROPERTIES GENERATED TRUE)
@@ -23,7 +25,8 @@
 TOLUA_FILE(dungeon w_dun.c)
 
 # tome executable
-INCLUDE_DIRECTORIES(lua)
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/lua)
 ADD_EXECUTABLE(tome main-gcu.c main-x11.c main-xaw.c main-sdl.c
   z-rand.c z-util.c z-form.c z-virt.c z-term.c z-sock.c
   variable.c tables.c plots.c util.c cave.c dungeon.c 
--- src/lua/lapi.c.orig	Mon Jan 18 16:13:46 2010
+++ src/lua/lapi.c	Sun Jan 31 20:54:18 2010
@@ -40,12 +40,17 @@
 
 
 static TObject *luaA_indexAcceptable (lua_State *L, int index) {
-  if (index >= 0) {
+  if (index == 0) {
+    return NULL;
+  } else if (index > 0) {
     TObject *o = L->Cbase+(index-1);
     if (o >= L->top) return NULL;
     else return o;
+  } else {
+    TObject *o = L->top+index;
+    if (o < L->Cbase) return NULL;
+    else return o;
   }
-  else return L->top+index;
 }
 
 
If I ever download a later snapshot, and I want to build another ToME executable, then I need to make all changes in the above diff, and also use my -L/usr/X11R6/lib workaround.

This was the day in the life of an OpenBSD user in the adventure to overcome the troubles of portability, to build the Troubles Of Middle-Earth.

Lord Estraven
Uruivellas
Posts: 718
Joined: Tue Dec 13, 2005 12:35 am

Re: ToME 2 maintenance

#18 Post by Lord Estraven »

Okay, I get this when building with cmake:

Code: Select all

gcc: /home/proteus/Games/tome2/w_mnster.c: No such file or directory
gcc: no input files
make[2]: *** [CMakeFiles/tome.dir/w_mnster.o] Error 1
make[1]: *** [CMakeFiles/tome.dir/all] Error 2
make: *** [all] Error 2

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

Re: ToME 2 maintenance

#19 Post by AnonymousHero »

Kernigh, all your fixes have been pushed to the repo. Thank you very much for all the hard work.

Just out of curiousity: Do you know if anyone has submitted a bug report for the -L switch problem with FindX11.cmake on OpenBSD? I don't think I'm going to try to carry around workarounds for such things in the CMake files in the ToME repo, but if this isn't like to get fixed upstream, then I'd be happy to add a little note to building.txt for now.

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

Re: ToME 2 maintenance

#20 Post by AnonymousHero »

Lord Estraven, did you do an out-of-source build? (I'm guessing that is the case from the error message.)

If so, this was broken (as Kernigh also noted), but has been fixed as a few minutes ago.

Kernigh
Wayist
Posts: 23
Joined: Sun Jan 31, 2010 3:55 pm

Re: ToME 2 maintenance

#21 Post by Kernigh »

AnonymousHero wrote:Just out of curiousity: Do you know if anyone has submitted a bug report for the -L switch problem with FindX11.cmake on OpenBSD? I don't think I'm going to try to carry around workarounds for such things in the CMake files in the ToME repo, but if this isn't like to get fixed upstream, then I'd be happy to add a little note to building.txt for now.
I look around the CMake bug tracker, but see no such bug report. I have not yet added a bug report, but I might later write a bug report. Upstream has fixed other bugs (like bug 3470), so they might fix this bug.

In building.txt, you might want to say what minimum version of CMake to use, and where to get it (http://www.cmake.org/cmake/resources/software.html). This will warn anyone who tries to use the OpenBSD package of CMake 2.4.8 with your 2.6 listfile.

I found an easier way to insert the -L/usr/X11R6/lib. The note for OpenBSD might say:

Code: Select all

Compiling on OpenBSD
====================

As of February 2010, the OpenBSD package cmake-2.4.8p2 is too old for
building ToME. You may need to compile a newer version of CMake.

If you have X11, then a bug in CMake may cause a linker error when
linking the 'tome' executable. As a workaround, set the environment
variable LDFLAGS=-L/usr/X11R6/lib when running CMake. Example:

       $ env LDFLAGS=-L/usr/X11R6/lib cmake .
       $ make

The SDL frontend also requires these packages: sdl-image, sdl-ttf

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

Re: ToME 2 maintenance

#22 Post by AnonymousHero »

I've added your notes to building.txt. Thanks for the copy.

EDIT: Ugh, I just noticed I forgot to credit you in the commit message. Sorry about that.

Lord Estraven
Uruivellas
Posts: 718
Joined: Tue Dec 13, 2005 12:35 am

Re: ToME 2 maintenance

#23 Post by Lord Estraven »

So... when do we get binary releases? :wink:

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

Re: ToME 2 maintenance

#24 Post by AnonymousHero »

Are you still having trouble compiling?

Re: Binary releases: I don't really think binary releases make much sense of *nix and I don't have any way to compile on Windows :(.

Lord Estraven
Uruivellas
Posts: 718
Joined: Tue Dec 13, 2005 12:35 am

Re: ToME 2 maintenance

#25 Post by Lord Estraven »

No problem compiling on *nix, it's just that Windows builds would be nice. (Especially seeing as Linux is becoming a real bugfest...)

wino45
Posts: 1
Joined: Mon Mar 01, 2010 6:59 pm

Re: ToME 2 maintenance

#26 Post by wino45 »

Hi

The Windows build from GIT repository is available here tome-2.3.8-git-win32.zip. Have fun, but keep in mind that is GIT build = UNTESTED. You have been warned.

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

Re: ToME 2 maintenance

#27 Post by AnonymousHero »

Just though I'd mention it here: I've pushed an update to the build system which should allow anyone to build on Windows with MinGW (thanks to wino45 for doing most of the work).

Shoob
Reaper
Posts: 1535
Joined: Mon Jan 22, 2007 6:31 pm
Location: East of the sun, west of the moon

Re: ToME 2 maintenance

#28 Post by Shoob »

just thought I would mention it here: building this on windows is fiendishly difficult, I have been trying for an hour or so, still got nothing to show for it... there is no really saying, you need to get cmake, etc, nor where to start building from, nor how to go about building it (your 2 lines of "how to" dont help much).

albeit, I have *never* compiled on windows before, only done it on unix/linux, so I dont know what I am doing.
Oliphant am I, and I never lie.

madmonk
Reaper
Posts: 2257
Joined: Wed Dec 12, 2007 12:21 am
Location: New Zealand

Re: ToME 2 maintenance

#29 Post by madmonk »

Go hereto compile on Windows...

Needs a bit of faffing around, but it is doable!
Regards

Jon.

Shoob
Reaper
Posts: 1535
Joined: Mon Jan 22, 2007 6:31 pm
Location: East of the sun, west of the moon

Re: ToME 2 maintenance

#30 Post by Shoob »

thanks, will try that later. (busy atm, hence, why I am on here... or rather, why am I on here...)
Oliphant am I, and I never lie.

Post Reply