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.
I now have an actual
tome executable, so I try to run it.
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.