logo logo

 Back to main page

The NWNX Community Forum

 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
Problems building core-2.8

 
Post new topic   Reply to topic    nwnx.org Forum Index -> Linux technical support
View previous topic :: View next topic  
Author Message
eeriegeek



Joined: 07 Jan 2008
Posts: 59

PostPosted: Thu Feb 23, 2012 2:43    Post subject: Problems building core-2.8 Reply with quote

In my ongoing saga of trying to upgrade my dev computer to fedora 16 I checked out the core-2.8 branch from git to build. I ran into a number of problems shown below. Some of these problems may be due to trying to use the bleeding edge release but any help is appreciated.

*******************************
#1
The install.sh script checks `uname -p`. I'm building in a full i386 chroot environment on x86_64 but `uname -p` reports the host architecture, not the the build environment. Something like `gcc -dumpmachine` might be a friendlier test. I ended up just building with individual commands.
Code:

autoconf
./configure --prefix=/home/nwn/server
make ODMBC_MYSQL=1


*******************************
#2
Code:

g++  -mtune=i386 -pipe  -Iinclude -DHAVE_CONFIG_H -I../.. -DMYSQL_SUPPORT  -c -o mysql.o mysql.cpp
g++ -w -fPIC -shared -W -Wall  -o nwnx_odbc_mysql_dynamic.so HookSCORCO.o CExoString.o ObjectStorage.o NWNXodbc.o plugin-odbc.o mysql.o -lz -lmysqlclient
/usr/bin/ld: cannot find -lmysqlclient
collect2: ld returned 1 exit status
make[2]: *** [nwnx_odbc_mysql_dynamic.so] Error 1
make[2]: Leaving directory `/home/nwn/build/nwnx2/nwnx2_svn_core28/nwnx2-linux/plugins/odmbc'
make[1]: *** [all] Error 2
make[1]: Leaving directory `/home/nwn/build/nwnx2/nwnx2_svn_core28/nwnx2-linux/plugins/odmbc'
make: *** [plugins/odmbc] Error 2

Make fails on DYNAMIC mysql target. Not sure if this is a fedora environment (this is a yum install of the mysql libraries) or build problem, but I fixed it by adding -L/usr/lib/mysql to LDFLAGS (export LDFLAGS=-L/usr/lib/mysql) and redoing configure/make.

*******************************
#3
Code:

g++  -mtune=i386 -pipe  -Iinclude -DHAVE_CONFIG_H -I../.. -DMYSQL_SUPPORT  -c -o mysql.o mysql.cpp
g++ -w -fPIC -shared -W -Wall -L/usr/lib/mysql -o nwnx_odbc_mysql_dynamic.so HookSCORCO.o CExoString.o ObjectStorage.o NWNXodbc.o plugin-odbc.o mysql.o -lz -lmysqlclient
make[2]: *** No rule to make target `-lmysqlclient', needed by `nwnx_odbc_mysql_static.so'.  Stop.
make[2]: Leaving directory `/home/nwn/build/nwnx2/nwnx2_svn_core28/nwnx2-linux/plugins/odmbc'
make[1]: *** [all] Error 2
make[1]: Leaving directory `/home/nwn/build/nwnx2/nwnx2_svn_core28/nwnx2-linux/plugins/odmbc'
make: *** [plugins/odmbc] Error 2

Make fails on STATIC mysql target. Not sure what is going on with this one. I saw elven was doing some updates here recently and this might be relelated. Not sure how to fix it, so commented out the make target for now and use the dyanamic build.

*******************************
#4
Code:

gcc -mtune=i386 -pipe -g -O2 -Wall -Werror -D_REENTRANT -D_THREAD_SAFE -I. -I.. -I../.. -I ../../include -I/usr/local/include -mtune=i386 -pipe  -Wall -Werror -D_REENTRANT -D_THREAD_SAFE -I. -I.. -I../.. -I ../../include -I/usr/local/include  -c -o hooks/h_ComputeSpellRange.o hooks/h_ComputeSpellRange.c
hooks/h_ComputeSpellRange.c: In function 'Hook_GetSpellRange':
hooks/h_ComputeSpellRange.c:36:10: error: variable 'no_bonus' set but not used [-Werror=unused-but-set-variable]
cc1: all warnings being treated as errors

make[1]: *** [hooks/h_ComputeSpellRange.o] Error 1
make[1]: Leaving directory `/home/nwn/build/nwnx2/nwnx2_svn_core28/nwnx2-linux/plugins/spells'
make: *** [plugins/spells] Error 2

Seems like a minor thing in h_ComputeSpellRange.c vs error checking. Should be easy to fix. I just commented out since I don't use it. After this, I get a clean build.

*******************************
#5
server console:
Code:

Starting NWSERVER Binary

NWNX2lib: Init
NWNX2lib: org SetString() at 0x81f41b4, new SetString() at 0xf77a428b
NWNX2lib: org GetObj() at 0x81f40bc, new GetObj() at 0xf77a42b3
* Parsing configuration...
NWN Extender v2.8-dev
(c) 2004 by the APS/NWNX Linux Conversion Group
(c) 2007-2010 by virusman and Acaos
Based on the Win32 version (c) 2003 by Ingmar Stieger (Papillon)
and Jeroen Broekhuizen
visit us at http://www.avlis.org

* Searching for signatures...
* Loading modules...
FIXES plugin registered.
ERROR: dlopen: ./nwnx_system.so: ./nwnx_system.so: undefined symbol: SystemStrCommandLookup
ERROR: dlopen: ./nwnx_funcs.so: ./nwnx_funcs.so: undefined symbol: FuncsStrCommandLookup
ODBC_MYSQL_DYNAMIC plugin registered.
* NWNX2 activated.
Neverwinter Nights Server
Build:8109
Copyright BioWare Corp 1998-2004

Server: Loading...
Server: Running...

Server: Loading module "ic209nwn169cep24a".....................................
Server: Module loaded
INIT(S): valid ret=0x082041ec
* Library ODBC!SPACER does not exist.
* Library ODBC!EXEC does not exist.
* Library ODBC!FETCH does not exist.
* Library FUNCS!GETTIMEOFDAY does not exist.

nwnx log:
Code:

NWN Extender v2.8-dev
--------------------------------
FIXES plugin registered.
Address: F73B0640
ERROR: dlopen: ./nwnx_system.so: ./nwnx_system.so: undefined symbol: SystemStrCommandLookup
ERROR: dlopen: ./nwnx_funcs.so: ./nwnx_funcs.so: undefined symbol: FuncsStrCommandLookup
ODBC_MYSQL_DYNAMIC: Supports the new plugin interface
ODBC_MYSQL_DYNAMIC plugin registered.
Address: F73A4DC0
* NWNX2 activated.

Two problems here, first the failed dlopen of nwnx_system.so and nwnx_funcs.so. I dug around a little in the code and it seems that this is related to some gperf generated files. Something may not be getting generated or linked, but I'm not sure what. Second, the odbc library is now working but the NWNX library name has changed from ODBC to ODBC_MYSQL_DYNAMIC. Patching this as needed in the nwscript (e.g. aps_include and the like) all calls must change from NWNX!ODBC!FETCH to NWNX!ODBC_MYSQL_DYNAMIC!FETCH and so on. Afer this fix I get successful database access.
[/code]
server console:
Code:

NWNX2 ODBC2 version 1.0.0 for Linux.
(c) 2005-2006 dumbo (dumbo@nm.ru)
(c) 2006-2010 virusman (virusman@virusman.ru)
MySQL engine is supported
Plugin link: F771B5E0
Plugin link: F771B5E0
o SCO located at 82d9c44.
o RCO located at 82d9b60.
o Connecting to 192.168.1.4, default port
o Connect successful.
o Got request: select unix_timestamp()
o Sent response (10 bytes): 1329942246


*******************************
#6
At this point the system is up and running minus the NWNX calls noted above. Normal sql queries are working until I attempt to retrieve a stored object. The server core dumps on a memory corruption detected by glibc in RetrieveCampaignObject. It does not seem to fault at the exact same spot, but always in RetrieveCampaignObject at what appears to be a free operation.
nwnscript:
Code:

string sSQL = "select item_object from persistent_chests where unique_id="+IntToString(nUniqueId);
DEBUG3("ee_fn_pchest: eePersistentChestOpenChest: SQL ["+sSQL+"]");
SetLocalString(GetModule(),"NWNX!ODBC_MYSQL_DYNAMIC!SETSCORCOSQL",sSQL);
object oItem = RetrieveCampaignObject("NWNX","-",locChest,oChest);

nwn server log:
Code:

[Wed Feb 22 17:13:19] DEBUG[3] ee_fn_pchest: eePersistentChestOpenChest: UniqueId [100]
[Wed Feb 22 17:13:19] DEBUG[3] ee_fn_pchest: eePersistentChestOpenChest: Retrieving item [0] id [62]
[Wed Feb 22 17:13:19] DEBUG[3] ee_fn_pchest: eePersistentChestOpenChest: SQL [select item_object from persistent_chests where unique_id=62]

server console:
Code:

*** glibc detected *** /home/nwn/server/nwserver: double free or corruption (!prev): 0x14b52690 ***
======= Backtrace: =========
/lib/libc.so.6(+0x75d22)[0xf75c8d22]
/lib/libc.so.6(+0x76e78)[0xf75c9e78]
/home/nwn/server/nwserver[0x830cdd6]

gdb backtrace:
Code:

#4  0xf75c8d22 in malloc_printerr (action=<optimized out>, str=<optimized out>, ptr=0x14b52690) at malloc.c:5021
        buf = "14b52690"
        cp = <optimized out>
#5  0xf75c9e78 in _int_free (av=0xf76fb3e0, p=0x14b52688, have_lock=0) at malloc.c:3942
        size = <optimized out>
        fb = <optimized out>
        nextchunk = <optimized out>
        nextsize = <optimized out>
        nextinuse = <optimized out>
        prevsize = <optimized out>
        bck = <optimized out>
        fwd = <optimized out>
        errstr = <optimized out>
        locked = <optimized out>
        __func__ = "_int_free"
#6  0x0830cdd6 in __builtin_delete (ptr=0x14b52690)
        ptr = 0x0
#7  0x082267c1 in CNWVirtualMachineCommands::ExecuteCommandRetrieveCampaignObject(int, int) ()
No symbol table info available.
#8  0x08231a7e in CNWVirtualMachineCommands::ExecuteCommand(int, int) ()
No symbol table info available.
#9  0x0826042e in CVirtualMachine::ExecuteCode(int *, char *, int, CVirtualMachineDebuggingContext *) ()
No symbol table info available.
#10 0x082627d7 in CVirtualMachine::RunScriptFile(int) ()
No symbol table info available.
#11 0x082621d3 in CVirtualMachine::RunScript(CExoString *, unsigned long, int) ()
No symbol table info available.
#12 0x081dfc8d in CNWSPlaceable::EventHandler(unsigned long, unsigned long, void *, unsigned long, unsigned long) ()
No symbol table info available.
---Type <return> to continue, or q <return> to quit---
#13 0x08095f96 in CServerAIMaster::UpdateState(void) ()
No symbol table info available.
#14 0x080a0530 in CServerExoAppInternal::MainLoop(void) ()
No symbol table info available.
#15 0x0804bbe7 in main ()
No symbol table info available.

and again, slightly different place, server console:
Code:

*** glibc detected *** /home/nwn/server/nwserver: free(): invalid pointer: 0xf7655418 ***
======= Backtrace: =========
/lib/libc.so.6(+0x75d22)[0xf7522d22]
/home/nwn/server/nwserver[0x830cdd6]

gdb backtrace:
Code:

#4  0xf7522d22 in malloc_printerr (action=<optimized out>, str=<optimized out>, ptr=0xf7655418) at malloc.c:5021
        buf = "f7655418"
        cp = <optimized out>
#5  0x0830cdd6 in __builtin_delete (ptr=0xf7655418)
        ptr = 0x0
#6  0x082b86a7 in CResGFF::~CResGFF(void) ()
No symbol table info available.
#7  0x082267b0 in CNWVirtualMachineCommands::ExecuteCommandRetrieveCampaignObject(int, int) ()
No symbol table info available.
#8  0x08231a7e in CNWVirtualMachineCommands::ExecuteCommand(int, int) ()
No symbol table info available.
#9  0x0826042e in CVirtualMachine::ExecuteCode(int *, char *, int, CVirtualMachineDebuggingContext *) ()
No symbol table info available.
#10 0x082627d7 in CVirtualMachine::RunScriptFile(int) ()
No symbol table info available.
#11 0x082621d3 in CVirtualMachine::RunScript(CExoString *, unsigned long, int) ()
No symbol table info available.
#12 0x081dfc8d in CNWSPlaceable::EventHandler(unsigned long, unsigned long, void *, unsigned long, unsigned long) ()
No symbol table info available.
#13 0x08095f96 in CServerAIMaster::UpdateState(void) ()
No symbol table info available.
#14 0x080a0530 in CServerExoAppInternal::MainLoop(void) ()
No symbol table info available.
#15 0x0804bbe7 in main ()
No symbol table info available.

Code:

$ uname -p
x86_64
$ gcc -dumpmachine
i686-redhat-linux
$ gcc --version
gcc (GCC) 4.6.2 20111027 (Red Hat 4.6.2-1)
$ ls -al /usr/lib/mysql
total 2844
drwxr-xr-x  2 root root    4096 Feb 22 14:05 .
dr-xr-xr-x 38 root root   16384 Feb 22 13:36 ..
lrwxrwxrwx  1 root root      20 Feb 13 13:26 libmysqlclient.so -> libmysqlclient.so.18
lrwxrwxrwx  1 root root      24 Feb 13 13:01 libmysqlclient.so.18 -> libmysqlclient.so.18.0.0
-rwxr-xr-x  1 root root 2881076 Jan 27 03:18 libmysqlclient.so.18.0.0
lrwxrwxrwx  1 root root      17 Feb 13 13:26 libmysqlclient_r.so -> libmysqlclient.so
-rwxr-xr-x  1 root root    7125 Jan 27 03:18 mysql_config
$ mysql_config --libs
-L/usr/lib/mysql -lmysqlclient -lpthread -lz -lm -lrt -lssl -lcrypto -ldl
Back to top
View user's profile Send private message
elven



Joined: 28 Jul 2006
Posts: 259
Location: Germany

PostPosted: Thu Feb 23, 2012 14:19    Post subject: Reply with quote

Hi,

regarding building core-2.8: I migrated core-2.8 to cmake, which does proper dependency handling (as opposed to the broken configure script we had). It should build fine with that without any env twiddling, given libmysqlclient is installed. I have also tweaked some of the build flags so that that warning will not make gcc bail anymore. Proper patches to address those issues will follow.

The mysql-rename-problem is known, and the easiest fix would have been to rename the binary of your choice to nwnx_odbc.so, as recommended in the downloadable builds. This will also receive a patch.

I have (just now) updated the git mirror on GH to reflect this. If you were kind enough to retry with a new checkout from git or svn, I'd be much obliged.

Alternatively, if you don't want to build yourself, you can also give the binaries produced by CI a shot.

Thanks for reporting the uname -p issue: it works on chroots running on Debian/Ubuntu. Not sure what's the difference on your environ.
Back to top
View user's profile Send private message
eeriegeek



Joined: 07 Jan 2008
Posts: 59

PostPosted: Thu Feb 23, 2012 17:15    Post subject: Reply with quote

Wow, thanks for the update and fast reply elven! I'll be trying all this out today and let you know how it goes.
Back to top
View user's profile Send private message
eeriegeek



Joined: 07 Jan 2008
Posts: 59

PostPosted: Fri Feb 24, 2012 6:22    Post subject: Reply with quote

Hey, an update on my fedora core 16 build attempt.. now using the new cmake check-in to build.

#4
The build fail on warning message in the spells plugin is gone. No problem there.

#5
Renaming the library nwnx_odmbc_mysql_dynamic.so to nwnx_odbc.so (or creating the symlink) works like a charm.

I finally tracked down the dload errors:
Code:

ERROR: dlopen: ./nwnx_system.so: ./nwnx_system.so: undefined symbol: SystemStrCommandLookup
ERROR: dlopen: ./nwnx_funcs.so: ./nwnx_funcs.so: undefined symbol: FuncsStrCommandLookup

It seems to be related to some combination of newer gperf versions and/or inline function handling and/or compiler flags. On a working system:
Code:

0000370c B Ref_TMILimit
00001891 t SystemObjCommandHash
00001899 t SystemObjCommandLookup
000017f0 t SystemStrCommandHash
0000181f t SystemStrCommandLookup
000035d8 a _DYNAMIC

vs a non-working
Code:

00003cac B Ref_TMILimit
         U SystemObjCommandLookup
         U SystemStrCommandLookup
00003ab8 a _DYNAMIC

And...
Code:

diff SystemStrCmds.h.good SystemStrCmds.h.bad
1c1
< /* ANSI-C code produced by gperf version 3.0.3 */
---
> /* ANSI-C code produced by gperf version 3.0.4 */
149c149
< #ifdef __GNUC_STDC_INLINE__
---
> #if defined __GNUC_STDC_INLINE__ || defined __GNUC_GNU_INLINE__

It seems maybe the hash functions are getting inlined away or something. It might be possible to fix this elegantly with the correct compiler flags in cmake, but I don't know enough cmake to try it yet. I fixed it with a patch to the gperf_gen.sh script to delete the offending compiler conditional.
Code:

diff --git a/plugins/gperf_gen.sh b/plugins/gperf_gen.sh
index 3624aa3..519739b 100755
--- a/plugins/gperf_gen.sh
+++ b/plugins/gperf_gen.sh
@@ -13,4 +13,6 @@ sed -i 's/\<\(\(MIN\|MAX\)_\(WORD_LENGTH\|HASH_VALUE\)\|TOTAL_KEYWORDS\)\>/NWNX_
 
 sed -i 's/^const struct/static const struct/' "gperf.out" || rm -f "gperf.out"
 
+sed -i 's/|| defined __GNUC_GNU_INLINE__//' "gperf.out" || rm -f "gperf.out"
+
 mv "gperf.out" "${V}Cmds.h"


I've gotten the database drivers to compile, but not "out of box". I'll post more on that in another post.
Back to top
View user's profile Send private message
elven



Joined: 28 Jul 2006
Posts: 259
Location: Germany

PostPosted: Fri Feb 24, 2012 16:26    Post subject: Reply with quote

I installed FC16 in a VM, and have reproduced the described problem. Good catch on that inline bug! I will see what can be done about that.

Also, MySQL (among others) won't compile, because /usr/lib/mysql isn't on the global search path for FC16. I will patch that into CMakeLists I guess.

btw, here is the background on the rename problem.
Back to top
View user's profile Send private message
eeriegeek



Joined: 07 Jan 2008
Posts: 59

PostPosted: Fri Feb 24, 2012 17:48    Post subject: Reply with quote

I think picking up the module name from the filename is actually quite elegant! I just missed that along the way in my build process. The only thing I would add is a clear note, maybe in the install script's post-install message to remind the installer to do it.

Before you go to crazy on the db cmake.. I lernt a little cmake yesterday and came up with this basically re-written CMakeList.txt for the odmbc directory that uses the default FindPostgreSQL cmake module target and two others I found on the internet for SQLite3 and MySQL.
Code:

cmake_minimum_required(VERSION 2.8)

set(all_deps HookSCORCO CExoString ObjectStorage NWNXodbc plugin-odbc)

set(CMAKE_VERBOSE_MAKEFILE on)

find_package(PostgreSQL)

if (PostgreSQL_FOUND)
        message("Found PostgreSQL installation!")
        message("PostgreSQL_INCLUDE_DIRS = " "${PostgreSQL_INCLUDE_DIRS}")
        message("PostgreSQL_LIBRARIES    = " "${PostgreSQL_LIBRARIES}")
        include_directories(${PostgreSQL_INCLUDE_DIRS})
        add_module(odmbc_pgsql_dynamic pgsql ${all_deps})
        target_link_libraries(odmbc_pgsql_dynamic ${PostgreSQL_LIBRARIES})
        set_target_properties(odmbc_pgsql_dynamic PROPERTIES COMPILE_FLAGS "-DPGSQL_SUPPORT=1")
else (PostgreSQL_FOUND)
        message(WARNING "PostgreSQL installation not found")
endif (PostgreSQL_FOUND)

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/CMakeModules")

message("CMAKE_MODULE_PATH = " "${CMAKE_MODULE_PATH}")

find_package(SQLite3)

if (SQLITE3_FOUND)
        message("Found SQLite3 installation!")
        message("SQLITE3_INCLUDE_DIRS = " "${SQLITE3_INCLUDE_DIRS}")
        message("SQLITE3_LIBRARIES    = " "${SQLITE3_LIBRARIES}")
        include_directories(${SQLITE3_INCLUDE_DIRS})
        add_module(odmbc_sqlite_dynamic sqlite ${all_deps})
        target_link_libraries(odmbc_sqlite_dynamic ${SQLITE3_LIBRARIES})
        set_target_properties(odmbc_sqlite_dynamic PROPERTIES COMPILE_FLAGS "-DSQLITE_SUPPORT=1")
else (SQLITE3_FOUND)
        message(WARNING "SQLite3 installation not found")
endif (SQLITE3_FOUND)

find_package(MySQL)

if (MYSQL_FOUND)
        message("Found MySQL installation!")
        message("MYSQL_INCLUDE_DIR = " "${MYSQL_INCLUDE_DIR}")
        message("MYSQL_LIBRARY     = " "${MYSQL_LIBRARY}")
        include_directories(${MYSQL_INCLUDE_DIR})
        add_module(odmbc_mysql_dynamic mysql ${all_deps})
        target_link_libraries(odmbc_mysql_dynamic ${MYSQL_LIBRARY})
        set_target_properties(odmbc_mysql_dynamic PROPERTIES COMPILE_FLAGS "-DMYSQL_SUPPORT=1")
else (MYSQL_FOUND)
        message(WARNING "MySQL installation not found")
endif (MYSQL_FOUND)

This does a nice job building the three dynamic libraries and I think is the cmake way. The only problem is I have not been able to get static build targets working. Mainly I'm having trouble finding current static libraries. I may try compiling my own from sources. I can post the FindSQLite3.make and FindMySQL.cmake modules I found and placed in the ${PROJECT_SOURCE_DIR}/CMakeModules directory.

Also, I did have to patch the include file name in the pgsql header file to get a compile. I'm not sure if the include path was a correct one for older postgress releases or just someone's local version, but it doesn't seem to be consistent with the include path generated by cmake's FindPostgreSQL module.
Code:

diff --git a/plugins/odmbc/pgsql.h b/plugins/odmbc/pgsql.h
index 7d113ae..e5a4e7e 100644
--- a/plugins/odmbc/pgsql.h
+++ b/plugins/odmbc/pgsql.h
@@ -22,7 +22,7 @@
 
 #include "db.h"
 
-#include <postgresql/libpq-fe.h>
+#include <libpq-fe.h>
 
 class CPgSQL : public CDB
 {


Last edited by eeriegeek on Fri Feb 24, 2012 20:30; edited 2 times in total
Back to top
View user's profile Send private message
eeriegeek



Joined: 07 Jan 2008
Posts: 59

PostPosted: Fri Feb 24, 2012 18:11    Post subject: Reply with quote

I'll just post the cmake database finder modules here since they aren't that long and somebody else my find them useful. I put them in a directory named CMakeModules at the project root.

FindMySQL.cmake
Code:

# - Find mysqlclient
# Find the native MySQL includes and library
#
#  MYSQL_INCLUDE_DIR - where to find mysql.h, etc.
#  MYSQL_LIBRARIES   - List of libraries when using MySQL.
#  MYSQL_FOUND       - True if MySQL found.

IF (MYSQL_INCLUDE_DIR)
  # Already in cache, be silent
  SET(MYSQL_FIND_QUIETLY TRUE)
ENDIF (MYSQL_INCLUDE_DIR)

FIND_PATH(MYSQL_INCLUDE_DIR mysql.h
  /usr/local/include/mysql
  /usr/include/mysql
)

SET(MYSQL_NAMES mysqlclient mysqlclient_r)
FIND_LIBRARY(MYSQL_LIBRARY
  NAMES ${MYSQL_NAMES}
  PATHS /usr/lib /usr/local/lib
  PATH_SUFFIXES mysql
)

IF (MYSQL_INCLUDE_DIR AND MYSQL_LIBRARY)
  SET(MYSQL_FOUND TRUE)
  SET( MYSQL_LIBRARIES ${MYSQL_LIBRARY} )
ELSE (MYSQL_INCLUDE_DIR AND MYSQL_LIBRARY)
  SET(MYSQL_FOUND FALSE)
  SET( MYSQL_LIBRARIES )
ENDIF (MYSQL_INCLUDE_DIR AND MYSQL_LIBRARY)

IF (MYSQL_FOUND)
  IF (NOT MYSQL_FIND_QUIETLY)
    MESSAGE(STATUS "Found MySQL: ${MYSQL_LIBRARY}")
  ENDIF (NOT MYSQL_FIND_QUIETLY)
ELSE (MYSQL_FOUND)
  IF (MYSQL_FIND_REQUIRED)
    MESSAGE(STATUS "Looked for MySQL libraries named ${MYSQL_NAMES}.")
    MESSAGE(FATAL_ERROR "Could NOT find MySQL library")
  ENDIF (MYSQL_FIND_REQUIRED)
ENDIF (MYSQL_FOUND)

MARK_AS_ADVANCED(
  MYSQL_LIBRARY
  MYSQL_INCLUDE_DIR
  )


FindSQLite3.cmake
Code:

# Copyright (C) 2007-2009 LuaDist.
# Created by Peter Kapec <kapecp@gmail.com>
# Redistribution and use of this file is allowed according to the terms of the MIT license.
# For details see the COPYRIGHT file distributed with LuaDist.
# Note:
# Searching headers and libraries is very simple and is NOT as powerful as scripts
# distributed with CMake, because LuaDist defines directories to search for.
# Everyone is encouraged to contact the author with improvements. Maybe this file
# becomes part of CMake distribution sometimes.
# - Find sqlite3
# Find the native SQLITE3 headers and libraries.
#
# SQLITE3_INCLUDE_DIRS - where to find sqlite3.h, etc.
# SQLITE3_LIBRARIES - List of libraries when using sqlite.
# SQLITE3_FOUND - True if sqlite found.
#
# 2012 - eeriegeek - modified lib name to sqlite3 for NWNX build
#

# Look for the header file.
FIND_PATH(SQLITE3_INCLUDE_DIR NAMES sqlite3.h)

# Look for the library.
FIND_LIBRARY(SQLITE3_LIBRARY NAMES sqlite3 libsqlite3)

# Handle the QUIETLY and REQUIRED arguments and set SQLITE3_FOUND to TRUE if all listed variables are TRUE.
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(SQLITE3 DEFAULT_MSG SQLITE3_LIBRARY SQLITE3_INCLUDE_DIR)

# Copy the results to the output variables.
IF(SQLITE3_FOUND)
SET(SQLITE3_LIBRARIES ${SQLITE3_LIBRARY})
SET(SQLITE3_INCLUDE_DIRS ${SQLITE3_INCLUDE_DIR})
ELSE(SQLITE3_FOUND)
SET(SQLITE3_LIBRARIES)
SET(SQLITE3_INCLUDE_DIRS)
ENDIF(SQLITE3_FOUND)

MARK_AS_ADVANCED(SQLITE3_INCLUDE_DIRS SQLITE3_LIBRARIES)

Back to top
View user's profile Send private message
elven



Joined: 28 Jul 2006
Posts: 259
Location: Germany

PostPosted: Sat Feb 25, 2012 1:23    Post subject: Reply with quote

eeriegeek wrote:
The only problem is I have not been able to get static build targets working. Mainly I'm having trouble finding current static libraries.


Thanks for fiddling with the package helpers on cmake. That was on the plan for me as well and I will probably integrate yours. I'll get back to those later, just meant to quickly point out:

building modules with symbols statically linked in from system libraries is very hard to automate, and will be flaky from environ to environ and from compiler to compiler. The compiler might even optimise some code out that is essential and break things in subtle ways at runtime.

The current static nwnx_mysql.so is basically a hackjob, since it's simpler than shipping the shared object that it was built against and making users put it on LD_LIBRARY_PATH. The old CMakeList relied on cmake finding the .a by just passing it by-name (but not all distros provide the .archive even so that's only known to work on debian squeeze).

The static build only exists because mysql is a real bitch regarding dynamically linking against binaries of other distros. It doesn't even work properly between ubuntu and debian. pq and sqlite3 doesn't have any problems with that, so dynamic builds should be fine there as long as the user installs the appropriate package (in fact, pq can't reasonably link statically without pulling in 30+MB of deps).
Back to top
View user's profile Send private message
elven



Joined: 28 Jul 2006
Posts: 259
Location: Germany

PostPosted: Sun Feb 26, 2012 18:30    Post subject: Reply with quote

I've committed your changes to my integration branch. I had to get FindPostgreSQL.cmake from Ubuntu, since the debian squeeze version can't find it's own installation. Ohwell. They will go into svn eventually ..

Also, mysql static builds are once again removed, since it breaks on Fedora.
Back to top
View user's profile Send private message
eeriegeek



Joined: 07 Jan 2008
Posts: 59

PostPosted: Fri Mar 02, 2012 10:56    Post subject: Reply with quote

Just as a quick summery, I think that all of my points above have been resolved or have solutions in the works except #7. I continue to get server crashes in RetrieveCampaignObject. This was happening in my core-2.8 Fedora Core 16 i386 chroot build. Since then I have set up a Fedora Core 14 i386 xen vm. The crash is happening in both my own build of core-2.8 and elven's latest integration build (static mysql). The stack traces are identical from both versions, and very similar to the Fedora Core 16 version.
Code:
Program terminated with signal 11, Segmentation fault.

#0  0x082b96ac in CResGFF::GetDataFromPointer(void *, int) ()
#1  0x08226308 in CNWVirtualMachineCommands::ExecuteCommandRetrieveCampaignObject(int, int) ()
#2  0x08231a7e in CNWVirtualMachineCommands::ExecuteCommand(int, int) ()
#3  0x0826042e in CVirtualMachine::ExecuteCode(int *, char *, int, CVirtualMachineDebuggingContext *) ()
#4  0x082627d7 in CVirtualMachine::RunScriptFile(int) ()
#5  0x082621d3 in CVirtualMachine::RunScript(CExoString *, unsigned long, int) ()
#6  0x081dfc8d in CNWSPlaceable::EventHandler(unsigned long, unsigned long, void *, unsigned long, unsigned long) ()
#7  0x08095f96 in CServerAIMaster::UpdateState(void) ()
#8  0x080a0530 in CServerExoAppInternal::MainLoop(void) ()
#9  0x0804bbe7 in main ()


However, after the migration back to FC 14, the latest checkout from svn trunc now builds and runs without crashing in RetrieveCampaignObject on FC 14 i386. I spent quite a while going through the code with no luck unfortunately.
Back to top
View user's profile Send private message
eeriegeek



Joined: 07 Jan 2008
Posts: 59

PostPosted: Sun Mar 11, 2012 4:47    Post subject: Reply with quote

Ok, I figured out what seems to be going on. It looks like in the move to cmake in core-2.8, the compiler flags from the make files have been lost/changed and some things were not at all happy about it. The most important seem to be -mtune=i386 -m32 and -fPIC. Without the i386 architecture flags, gcc generates alternate stack frame handling which does not play well with the hooks procedures like RCOproc in particular, causing memory corruption which was generally showing up as a random error in memory management a few moments later.
Code:
    5632:   eb 05                   jmp    5639 <_Z7RCOprocPKiPPcS2_S2_PiS3_+0x6a>
    5634:   b8 00 00 00 00          mov    $0x0,%eax
    5639:   c9                      leave
    563a:   c3                      ret

vs
Code:
    530d:   eb 05                   jmp    5314 <_Z7RCOprocPKiPPcS2_S2_PiS3_+0x8d>
    530f:   b8 00 00 00 00          mov    $0x0,%eax
    5314:   83 c4 30                add    $0x30,%esp
    5317:   5b                      pop    %ebx
    5318:   5e                      pop    %esi
    5319:   5d                      pop    %ebp
    531a:   c3                      ret


... for example was causing a seg fault after RetrieveCampaignObject. For -fPIC, the problem is the opposite, it was not specified in the make files, but was in cmake, plus cmake adds it by default for all shared libraries. Addition of the references to the global relocation redirects by fPIC were causing seg faults in the profiler and chat plugins at least. Anyway, the following changes to the top level CMakeLists.txt file seems to have gotten things working again.
Code:

set(CMAKE_C_FLAGS "-mtune=i386 -m32 -Wall -Wno-unused -Wno-write-strings")
set(CMAKE_CXX_FLAGS "-mtune=i386 -m32 -Wall -Wno-unused -Wno-write-strings")
set(CMAKE_SHARED_LIBRARY_C_FLAGS "")
set(CMAKE_SHARED_LIBRARY_CXX_FLAGS "")

I'm not sure if setting this for everything is the best way. It may be that only some of the hook code requires it. On the other hand, there probably won't be too many other applications trying to load these shared libraries. At any rate, it explains why the trunk builds with make were working fine on the same host.
Back to top
View user's profile Send private message
elven



Joined: 28 Jul 2006
Posts: 259
Location: Germany

PostPosted: Wed Mar 21, 2012 13:42    Post subject: Reply with quote

That's a very good find. I haven't yet verified it myself, but I still took the liberty of incorporating your fix. Reasoning seems sound and the resulting code works.

Thanks for your detective work ..
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    nwnx.org Forum Index -> Linux technical support All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group