Jump to content
  • 0

Linker error building mangos two on FreeBSD


Kerr0r

Question

I'm having trouble building on FreeBSD.

This is without "use external ACE" checked, as that failed even harder. At first it couldn't even find -lACE, some tweaking later I got page upon page of undefined references to all sorts of stuff.

Output from running make, after adding -v to linker flags:

[mangos@mangostwo ~/two/src/server/linux]$ make
[ 26%] Built target ace
[ 29%] Built target lualib
[ 30%] Built target bzip2
[ 31%] Built target libmpq
[ 32%] Built target detour
[ 33%] Built target recast
[ 37%] Built target g3dlite
[ 39%] Built target zlib
[ 39%] Built target loadlib
[ 39%] Built target framework
[ 41%] Built target shared
[ 42%] Built target realmd
[ 42%] Built target pchdef.cpp_dephelp
[ 42%] Built target generate_pchdef.cpp
[ 42%] Built target precompiled.cpp_dephelp
[ 42%] Built target generate_precompiled.cpp
[ 82%] Built target mangosscript
[ 83%] Built target LuaEngine
[ 98%] Built target game
[ 98%] Linking CXX executable mangosd
FreeBSD clang version 6.0.0 (tags/RELEASE_600/final 326565) (based on LLVM 6.0.0)
Target: x86_64-unknown-freebsd11.2
Thread model: posix
InstalledDir: /usr/bin
 "/usr/bin/ld" --eh-frame-hdr -dynamic-linker /libexec/ld-elf.so.1 --hash-style=both --enable-new-dtags -o mangosd /usr/lib/crt1.o /usr/lib/crti.o /usr/lib/crtbegin.o -L/home/mangos/two/src/server/linux/dep/acelite/ace -L/usr/lib --no-as-needed -lrt CMakeFiles/mangosd.dir/AFThread.cpp.o CMakeFiles/mangosd.dir/CliThread.cpp.o CMakeFiles/mangosd.dir/RAThread.cpp.o CMakeFiles/mangosd.dir/WorldThread.cpp.o CMakeFiles/mangosd.dir/mangosd.cpp.o -rpath /home/mangos/two/src/server/linux/dep/acelite/ace:/usr/local/lib:/usr/local/lib/mysql: ../game/libgame.a ../shared/libshared.a ../framework/libframework.a ../../dep/g3dlite/libg3dlite.a /usr/local/lib/libssl.so /usr/local/lib/libcrypto.so ../../dep/acelite/ace/libace.a /usr/local/lib/mysql/libmysqlclient.so -lz ../../dep/recastnavigation/Detour/Source/libdetour.a ../modules/SD3/libmangosscript.a ../modules/Eluna/libLuaEngine.a ../../dep/lualib/liblualib.a -lc++ -lm -lgcc --as-needed -lgcc_s --no-as-needed -lpthread -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib/crtend.o /usr/lib/crtn.o
../modules/Eluna/libLuaEngine.a(LuaFunctions.cpp.o): In function `ElunaTemplate<unsigned long long>::Pow(lua_State*)':
LuaFunctions.cpp:(.text+0x1cb6d): warning: powl has lower than advertised precision
../../dep/lualib/liblualib.a(loslib.c.o): In function `os_tmpname':
loslib.c:(.text+0x8a7): warning: warning: tmpnam() possibly used unsafely; consider using mkstemp()
../../dep/acelite/ace/libace.a(OS_NS_stdio.cpp.o): In function `ACE_OS::tempnam(char const*, char const*)':
OS_NS_stdio.cpp:(.text+0x12d6): warning: warning: tempnam() possibly used unsafely; consider using mkstemp()
../../dep/acelite/ace/libace.a(OS_NS_stdlib.cpp.o): In function `ACE_OS::mktemp(char*)':
OS_NS_stdlib.cpp:(.text+0xcb6): warning: warning: mktemp() possibly used unsafely; consider using mkstemp()
/usr/bin/ld: warning: libssl.so.8, needed by /usr/local/lib/mysql/libmysqlclient.so, may conflict with libssl.so.9
/usr/bin/ld: warning: libcrypto.so.8, needed by /usr/local/lib/mysql/libmysqlclient.so, may conflict with libcrypto.so.9
../game/libgame.a(WorldSocketMgr.cpp.o): In function `ACE_Acceptor<WorldSocket, ACE_SOCK_Acceptor>::open(ACE_INET_Addr const&, ACE_Reactor*, int, int, int)':
WorldSocketMgr.cpp:(.text._ZN12ACE_AcceptorI11WorldSocket17ACE_SOCK_AcceptorE4openERK13ACE_INET_AddrP11ACE_Reactoriii[_ZN12ACE_AcceptorI11WorldSocket17ACE_SOCK_AcceptorE4openERK13ACE_INET_AddrP11ACE_Reactoriii]+0x33): undefined reference to `ACE_INET_Addr::operator=(ACE_INET_Addr const&)'
WorldSocketMgr.cpp:(.text._ZN12ACE_AcceptorI11WorldSocket17ACE_SOCK_AcceptorE4openERK13ACE_INET_AddrP11ACE_Reactoriii[_ZN12ACE_AcceptorI11WorldSocket17ACE_SOCK_AcceptorE4openERK13ACE_INET_AddrP11ACE_Reactoriii]+0x5c): undefined reference to `ACE_SOCK_Acceptor::open(ACE_Addr const&, int, int, int, int, int)'
../modules/Eluna/libLuaEngine.a(LuaEngine.cpp.o): In function `Eluna::GetScripts(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >)':
LuaEngine.cpp:(.text+0x523): undefined reference to `ACE_Dirent::ACE_Dirent()'
LuaEngine.cpp:(.text+0x547): undefined reference to `ACE_Dirent::open(char const*)'
LuaEngine.cpp:(.text+0x78d): undefined reference to `ACE_Dirent::read()'
LuaEngine.cpp:(.text+0xa12): undefined reference to `ACE_Dirent::~ACE_Dirent()'
LuaEngine.cpp:(.text+0xc46): undefined reference to `ACE_Dirent::~ACE_Dirent()'
LuaEngine.cpp:(.text+0xced): undefined reference to `ACE_Dirent::~ACE_Dirent()'
LuaEngine.cpp:(.text+0xd16): undefined reference to `ACE_Dirent::~ACE_Dirent()'
LuaEngine.cpp:(.text+0xd2c): undefined reference to `ACE_Dirent::~ACE_Dirent()'
c++: error: linker command failed with exit code 1 (use -v to see invocation)
*** Error code 1

Stop.
make[2]: stopped in /usr/home/mangos/two/src/server/linux
*** Error code 1

Stop.
make[1]: stopped in /usr/home/mangos/two/src/server/linux
*** Error code 1

Stop.
make: stopped in /usr/home/mangos/two/src/server/linux

libace.a is certainly being linked. Looking for some of the functions it complains about, we can see that they are present:

root@mangostwo:/home/mangos/two/src/server/linux # nm dep/acelite/ace/libace.a | grep ACE_Dirent
0000000000000000 T _ZN10ACE_Dirent4openEPKc
0000000000000110 T _ZN10ACE_Dirent4readEP6direntPS1_
00000000000000f0 T _ZN10ACE_Dirent4readEv
0000000000000180 T _ZN10ACE_Dirent4seekEl
00000000000001a0 T _ZN10ACE_Dirent4tellEv
0000000000000130 T _ZN10ACE_Dirent5closeEv
0000000000000160 T _ZN10ACE_Dirent6rewindEv
0000000000000050 T _ZN10ACE_DirentC1EPKc
0000000000000040 T _ZN10ACE_DirentC1Ev
0000000000000050 T _ZN10ACE_DirentC2EPKc
0000000000000040 T _ZN10ACE_DirentC2Ev
00000000000000d0 T _ZN10ACE_DirentD1Ev
00000000000000d0 T _ZN10ACE_DirentD2Ev
0000000000000160 T _ZN19ACE_Dirent_Selector4openEPKcPFiPK6direntEPFiPS4_S7_E
00000000000000b0 T _ZN19ACE_Dirent_Selector5closeEv
0000000000000030 T _ZN19ACE_Dirent_SelectorC1Ev
0000000000000030 T _ZN19ACE_Dirent_SelectorC2Ev
0000000000000100 T _ZN19ACE_Dirent_SelectorD0Ev
0000000000000050 T _ZN19ACE_Dirent_SelectorD1Ev
0000000000000050 T _ZN19ACE_Dirent_SelectorD2Ev
0000000000000000 T _ZNK19ACE_Dirent_Selector6lengthEv
0000000000000010 T _ZNK19ACE_Dirent_SelectorixEi
0000000000000038 R _ZTI19ACE_Dirent_Selector
0000000000000020 R _ZTS19ACE_Dirent_Selector
0000000000000000 R _ZTV19ACE_Dirent_Selector

Any idea how I can fix this?

Edited by Kerr0r
Solved it (kinda)
Link to comment
Share on other sites

1 answer to this question

Recommended Posts

  • 0

I was finally able to solve this myself, after much mucking. I'm not sure how to make these changes in the "proper" way, but hopefully this will be useful to someone. Either someone making a patch, or someone who's just struggling to make it work for themselves.

Cannot find -lACE

Assuming you actually have ACE installed, this indicates that you need to add the location of the library. I did

target_link_libraries(${EXECUTABLE_NAME} -L/usr/local/lib)

I'm sure there's a more general way to add the location of ACE.

Undefined reference to <a few things>

One of the binaries (mangosd I think) had ACE listed before libshared.a. Ordering of arguments to the linker matters, so place ACE last.

Undefined reference to <lots of things>

Quite a few ACE functions are meant to be inlined, and as such are not included in the .so file. But to inline them, __ACE_INLINE__ needs to be defined. I added add_compile_definitions(__ACE_INLINE__) to the root CMakeLists.txt.

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