Jump to content

[fixed] Scripting Library Not Found after installing with cmake


antiroot

Recommended Posts

Finally got around to building the latest revision with cmake and after some slight tweaking with 3rd party patches was able to get most of everything working, however the scripting library cannot be loaded/found by mangosd

Note about sysem

32-Bit FreeBSD 7.2

using external ACE-6.0.0, compiled with default configurations (bundled will not compile under freebsd)

I receive the following in my logs

2011-02-20 18:14:26 Initializing Scripts...
2011-02-20 18:14:26 ERROR:Scripting library not found or not accessible.

I thought maybe one of my patches were at fault so I disabled all custom patches, still got the error. Disabled SD2 and compiled with generic scripting library and still got the error

So far I'm sure about the following

Its a not a permissions issue, everything is owned by the same user that mangosd runs as

The file does exist, and is not empty (assuming that it has the correct name)

libmangosscript.so is compiled to mangos/lib/ but

ldd mangos/bin/mangosd

does not say that mangosd is linked to the library at all, all other builds prior to using cmake would have a listing for libmysqlscript.so.0

any ideas would be appreciated thanks

Link to comment
Share on other sites

Hm i'm really no BSD expert.

On Linux, it is correct that mangosd does not depend on the scripting lib, and i always wondered why it did (looked like an old workaround to me).

The scripting library is explicitly loaded by core, and the search path is set in the binary through the Rpath mechanism.

On BSD, this command should (hopefully) show the Rpath:

$ elfdump -L mangosd | grep Rpath

If this for some reason doesn't point to the scripting lib, you can probably work around by adding the path to ldconfig, if that works on BSD in the same way as on Linux.

Link to comment
Share on other sites

When i do test install mangos at FreeBSD i see in install log:
-- Set runtime path of "*/mangos/lib/libmangosscript.so" to "*/mangos/lib"

Maybe you not have at mangos build proper install dir as path where mangos will executed?

all install and compilation with DPREFIX from root /

test# ldd mangosd
mangosd:
       libACE-5.8.3.so => /home/wow/mangos/lib/libACE-5.8.3.so (0x286ad000)
       libmysqlclient_r.so.16 => /usr/local/lib/mysql/libmysqlclient_r.so.16 (0x28808000)
       libssl.so.6 => /usr/lib/libssl.so.6 (0x28874000)
       libcrypto.so.6 => /lib/libcrypto.so.6 (0x288ba000)
       libz.so.5 => /lib/libz.so.5 (0x28a16000)
       libtbb_debug.so => /home/wow/mangos/lib/libtbb_debug.so (0x28a28000)
       libtbbmalloc_debug.so => /home/wow/mangos/lib/libtbbmalloc_debug.so (0x28a67000)
       libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x28a77000)
       libm.so.5 => /lib/libm.so.5 (0x28b6b000)
       libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x28b85000)
       libthr.so.3 => /lib/libthr.so.3 (0x28b90000)
       libc.so.7 => /lib/libc.so.7 (0x28ba5000)
       libcrypt.so.5 => /lib/libcrypt.so.5 (0x28cbd000)
test#

install log:

[  0%] Built target genrev
[  0%] Built target revision.h
[  1%] Built target TBB_Project
[  2%] Built target ACE_Project
[  7%] Built target g3dlite
[  7%] Built target gsoap
[ 74%] Built target mangosscript
[ 74%] Built target framework
[ 78%] Built target shared
[ 78%] Built target realmd
[ 99%] Built target game
[100%] Built target mangosd
Install the project...
-- Install configuration: "Release"
-- Installing: /home/wow/server/lib
-- Installing: /home/wow/server/lib/libtbb.so
-- Installing: /home/wow/server/lib/libtbbmalloc.so
-- Installing: /home/wow/server/lib
-- Installing: /home/wow/server/lib/libtbb_debug.so
-- Installing: /home/wow/server/lib/libtbbmalloc_debug.so
-- Installing: /home/wow/server/lib/libmangosscript.so
-- Installing: /home/wow/server/etc/scriptdev2.conf.dist
-- Installing: /home/wow/server/bin/realmd
-- Installing: /home/wow/server/etc/realmd.conf.dist
-- Installing: /home/wow/server/bin/mangosd
-- Installing: /home/wow/server/bin/run-mangosd
-- Installing: /home/wow/server/etc/mangosd.conf.dist

Link to comment
Share on other sites

When i do test install mangos at FreeBSD i see in install log:
-- Set runtime path of "*/mangos/lib/libmangosscript.so" to "*/mangos/lib"

Maybe you not have at mangos build proper install dir as path where mangos will executed?

I saw that log also

however doing elfdump like Lynx3d suggested shows

elfdump -d /opt/mangos/bin/mangosd

entry: 12

d_tag: DT_RPATH

d_val: /opt/mangos/lib:/usr/local/lib:/usr/local/lib/mysql

elfdump -d /opt/mangos/lib/libmangosscript.so

entry: 6

d_tag: DT_RPATH

d_val: /opt/mangos/lib

Edit:

Also i built it using these exact steps.. all patches, sd2 removed since this issue occurred for me with clean mangos

git clone git://github.com/mangos/mangos.git ~/mangos
cd ~/mangos
mkdir objdir
cmake ../ -DACE_USE_EXTERNAL=1 -DPREFIX=/opt/mangos/
make
make install
make clean

Another Edit:

just tried adding /opt/mangos/lib/ to ldconfig still no change

Link to comment
Share on other sites

same here, library still is not seen

compiled in DEBUG, and installed gdb on server and was able to get this much

Breakpoint 2, World::SetInitialWorldSettings (this=0x28ee3200) at /root/mangos/src/game/World.cpp:1262
1262        switch(sScriptMgr.LoadScriptLibrary(MANGOS_SCRIPT_NAME))
(gdb) step
MaNGOS::Singleton<ScriptMgr, MaNGOS::SingleThreaded<ScriptMgr>, MaNGOS::OperatorNew<ScriptMgr>, MaNGOS::ObjectLifeTime<ScriptMgr> >::Instance ()
   at /root/mangos/src/framework/Policies/SingletonImp.h:36
36          if (!si_instance)
(gdb)
54          return *si_instance;
(gdb)


ScriptMgr::LoadScriptLibrary (this=0x28e84a40, libName=0x8637837 "mangosscript") at /root/mangos/src/game/ScriptMgr.cpp:1049
1049        UnloadScriptLibrary();
(gdb)
ScriptMgr::UnloadScriptLibrary (this=0x28e84a40) at /root/mangos/src/game/ScriptMgr.cpp:1113
1113        if (!m_hScriptLib)
(gdb)
1150    }
(gdb)
ScriptMgr::LoadScriptLibrary (this=0x28e84a40, libName=0x8637837 "mangosscript") at /root/mangos/src/game/ScriptMgr.cpp:1051
1051        std::string name = libName;
(gdb)
1052        name = MANGOS_SCRIPT_PREFIX + name + MANGOS_SCRIPT_SUFFIX;
(gdb)
std::operator+<char, std::char_traits<char>, std::allocator<char> > (__lhs=0x8624d50 "lib", __rhs=...) at /usr/include/c++/4.2/bits/basic_string.tcc:680
680           const __size_type __len = _Traits::length(__lhs);
(gdb)
std::char_traits<char>::length (__s=0x8624d50 "lib") at /usr/include/c++/4.2/bits/char_traits.h:258
258           { return strlen(__s); }
(gdb)
std::operator+<char, std::char_traits<char>, std::allocator<char> > (__lhs=0x8624d50 "lib", __rhs=...) at /usr/include/c++/4.2/bits/basic_string.tcc:681
681           __string_type __str;
(gdb)
682           __str.reserve(__len + __rhs.size());
(gdb)
683           __str.append(__lhs, __len);
(gdb)
684           __str.append(__rhs);
(gdb)
std::operator+<char, std::char_traits<char>, std::allocator<char> > (__lhs=..., __rhs=0x8624d54 ".so") at /usr/include/c++/4.2/bits/basic_string.h:2111
2111          basic_string<_CharT, _Traits, _Alloc> __str(__lhs);
(gdb)
2112          __str.append(__rhs);
(gdb)
ScriptMgr::LoadScriptLibrary (this=0x28e84a40, libName=0x8637837 "mangosscript") at /root/mangos/src/game/ScriptMgr.cpp:1054
1054        m_hScriptLib = MANGOS_LOAD_LIBRARY(name.c_str());
(gdb)
ACE_OS::dlopen (fname=0x3978a4dc "libmangosscript.so", mode=257) at /usr/local/include/ace/OS_NS_dlfcn.inl:124
124       ACE_OSCALL
(gdb)
144       return handle;
(gdb)
189     }
(gdb)
ScriptMgr::LoadScriptLibrary (this=0x28e84a40, libName=0x8637837 "mangosscript") at /root/mangos/src/game/ScriptMgr.cpp:1056
1056        if (!m_hScriptLib)
(gdb)
1057            return SCRIPT_LOAD_ERR_NOT_FOUND;
(gdb)
1109    }
(gdb)
World::SetInitialWorldSettings (this=0x28ee3200) at /root/mangos/src/game/World.cpp:1268
1268                sLog.outError("Scripting library not found or not accessible.");

Edited: @ 124 ACE_OSCALL, gdb appeared to be unresponsive and was using 25% cpu, i thought it halted but after posting this it continued seconds later. All i can conclude from this is at least the library name is correct "libmangosscript.so" but I'm thinking ACE_OS::dlopen is not being friendly with freebsd

Link to comment
Share on other sites

Added dlerror call after MANGOS_LOAD_LIBRARY

This is with SD2

2011-02-22 14:20:21 ERROR:ACE_OS::dlerror() -  /opt/mangos/lib/libmangosscript.so: Undefined symbol "_ZN10CreatureAI12CanCastSpellEP4UnitPK10SpellEntryb".

Edit:

without SD2

2011-02-22 15:07:12 ERROR:ACE_OS::dlerror() -  Shared object "libmangosscript.so" not found, required by "mangosd".

after looking at bindings/CMakeLists.txt i noticed that "add_subdirectory(universal)" is commented out so this would explain why its not found when compiling without SD2

So to me this looks like its an SD2 issue and i should post over there after a little more research

it looks to me like CreatureAI isn't being included/linked into mangosscript correctly, but I'm not sure where exactly the problem is, just looks like SD2 problem to me but i could be wrong

Link to comment
Share on other sites

Oh...not necessarily SD2 fault. Symbols from core not properly exported for use in dynamic libraries.

Maybe adding '-rdynamic' (or '-export-dynamic', people can't seem to decide...) to the link flags of mangosd already does the trick.

Don't ask me what exactly the linux setup of cmake does differently here, because "backwards referencing" of symbols does not magically work on linux either...

On my own build setup (using waf) i need to specify '-rdynamic' for mangosd too, cmake doesn't, but it doesn't use '-Wl,-Bsymbolic-functions' either...couldn't see any other difference.

So maybe try in src/mangosd/CMakeLists.txt

if(UNIX)
 set(EXECUTABLE_LINK_FLAGS "-pthread ${EXECUTABLE_LINK_FLAGS} -rdynamic")
endif()

Link to comment
Share on other sites

Thanks a lot both lynx3d and vladimir

adding the -rdynamic flag resolved the issue

diff --git a/src/mangosd/CMakeLists.txt b/src/mangosd/CMakeLists.txt
index 074b692..2966707 100644
--- a/src/mangosd/CMakeLists.txt
+++ b/src/mangosd/CMakeLists.txt
@@ -77,7 +77,7 @@ endif()
set(EXECUTABLE_LINK_FLAGS "")

if(UNIX)
-  set(EXECUTABLE_LINK_FLAGS "-pthread ${EXECUTABLE_LINK_FLAGS}")
+  set(EXECUTABLE_LINK_FLAGS "-pthread ${EXECUTABLE_LINK_FLAGS} -rdynamic")
endif()

if(APPLE)

in case metacero or any other freebsd users need to know exactly where the change was made

.server info

Using script library: ScriptDev2 (for MaNGOS 11167+) Revision [37d02ac88add5c131db7230055ad57a5b7a287ba] * * (Unix)

just ran through some areas that i know were sd2 scripted and everything is running correctly

Link to comment
Share on other sites

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy Terms of Use