There are many threads with compilation errors, but I did not find any with full instruction how to fix all problems.
For people familiar with 'git compare':
1) All errors fixed one by one:
gesior/tfs_0.4_on_debian_10 (https://github.com/gesior/tfs_0.4_on_debian_10/commits/main)
2) Total diff of TFS 0.4 rev 3777 update to compile it on Debian 10:
gesior/tfs_0.4_on_debian_10 (https://github.com/gesior/tfs_0.4_on_debian_10/compare/c215d09...9664f12)
TFS 0.4 rev 3777 sources updated to compile on Debian 10:
gesior/tfs_0.4_on_debian_10 (https://github.com/gesior/tfs_0.4_on_debian_10)
Packages required to compile old engines on Debian 10:
Code:
apt install libboost-all-dev libgmp3-dev liblua5.1-0 liblua5.1-0-dev lua5.1 libxml2-dev libxml++2.6-dev zlib1g-dev zlib1g libcrypto++-dev libcrypto++6 libssl-dev libmariadb-dev libmariadb-dev-compat cpp gcc g++ make autoconf
TFS 0.4 commands to compile on Debian 10:
Code:
sh autogen.sh
./configure --enable-mysql --disable-dependency-tracking
sh build.sh
Step by step error fixing instruction:
0) Get some program to search in all files in 'sources' directory, like Notepad++/Sublime Text, some IDE or in case of linux terminal "grep -R"
1) Error:
Code:
checking boost/tr1/unordered_set.hpp usability... no
checking boost/tr1/unordered_set.hpp presence... no
checking for boost/tr1/unordered_set.hpp... no
configure: error: "boost::unordered_set header not found."
Search in
all files in 'sources' directory.
Replace every:
with:
Replace every:
with:
2) Error:
Code:
chat.cpp: In member function ‘ChatChannel* Chat::getChannel(Player*, uint16_t)’:
chat.cpp:1144:10: error: cannot convert ‘bool’ to ‘ChatChannel*’ in return
1144 | return false;
replace at 1144 line - it's in function "ChatChannel* Chat::getChannel(Player*, uint16_t)" - of
chat.cpp:
with:
3) Error:
Code:
connection.cpp: In member function ‘void Connection::accept()’:
connection.cpp:323:82: error: no matching function for call to ‘boost::posix_time::seconds::seconds(Connection::<unnamed enum>)’
323 | m_readTimer.expires_from_now(boost::posix_time::seconds(Connection::readTimeout));
...
(it throws around 100 lines of errors)
In
connection.cpp and
connection.h - some searches may return 0 results, it's fine.
Replace every:
with:
Replace every:
with:
Replace every:
with:
Replace every:
Code:
Connection::write_timeout
with:
in
connection.h remove:
Code:
enum {writeTimeout = 30};
enum {readTimeout = 30};
in
connection.h above:
add:
Code:
static constexpr int32_t CONNECTION_WRITE_TIMEOUT = 30;
static constexpr int32_t CONNECTION_READ_TIMEOUT = 30;
4) Error:
Code:
game.cpp: In member function ‘Item* Game::findItemOfType(Cylinder*, uint16_t, bool, int32_t)’:
game.cpp:1725:10: error: cannot convert ‘bool’ to ‘Item*’ in return
1725 | return false;
replace at 1725 line - it's in function "Item* Game::findItemOfType(Cylinder*, uint16_t, bool, int32_t)" - of
game.cpp:
with:
5) Error:
Code:
luascript.cpp: In member function ‘bool LuaInterface::loadDirectory(const string&, Npc*)’:
luascript.cpp:741:23: error: ‘class boost::filesystem::directory_entry’ has no member named ‘leaf’
741 | std::string s = it->leaf();
In
luascript.cpp replace every:
with:
Code:
->path().filename().string()
6) Error:
Code:
protocolgame.cpp: In member function ‘virtual void ProtocolGame::parsePacket(NetworkMessage&)’:
protocolgame.cpp:826:54: error: no match for ‘operator<<’ (operand types are ‘std::basic_ostream<char>’ and ‘std::stringstream’ {aka ‘std::__cxx11::basic_stringstream<char>’})
826 | s << player->getName() << " sent unknown byte: " << hex << std::endl;
or:
Code:
protocolgame.cpp:955:28: error: cannot bind ‘std::basic_ostream<char>’ lvalue to ‘std::basic_ostream<char>&&’
s << player->getName() << " sent unknown byte: " << hex << std::endl;
In
protocolgame.cpp replace:
Code:
s << player->getName() << " sent unknown byte: " << hex << std::endl;
with:
Code:
s << player->getName() << " sent unknown byte: " << hex.str() << std::endl;
7) Error:
Code:
scriptmanager.cpp: In member function ‘bool ScriptManager::loadMods()’:
scriptmanager.cpp:130:23: error: ‘class boost::filesystem::directory_entry’ has no member named ‘leaf’
130 | std::string s = it->leaf();
In
scriptmanager.cpp replace every:
with:
Code:
->path().filename().string()
8) Error:
Code:
talkaction.cpp: In member function ‘bool TalkActions::onPlayerSay(Creature*, uint16_t, const string&, bool)’:
talkaction.cpp:137:37: error: array must be initialized with a brace-enclosed initializer
137 | std::string cmd[TALKFILTER_LAST] = words, param[TALKFILTER_LAST] = "";
| ^~~~~
talkaction.cpp:137:69: error: array must be initialized with a brace-enclosed initializer
137 | std::string cmd[TALKFILTER_LAST] = words, param[TALKFILTER_LAST] = "";
In
talkaction.cpp replace:
Code:
std::string cmd[TALKFILTER_LAST] = words, param[TALKFILTER_LAST] = "";
with:
Code:
std::string cmd[TALKFILTER_LAST] = {words, words, words}, param[TALKFILTER_LAST] = {"", "", ""};
9) Error at end of compilation:
Code:
/usr/bin/ld: connection.o: undefined reference to symbol 'pthread_condattr_setclock@@GLIBC_2.3.3'
/usr/bin/ld: /lib/x86_64-linux-gnu/libpthread.so.0: error adding symbols: DSO missing from command line
In
configure.ac replace:
with:
Code:
LIBS="$LIBS $XML_LIBS -lpthread"
10) Random C++ errors - warnings handled as errors, because of configuration.
Before you start searching on forum, why it does not compile, edit file
makefile.am:
Search and
remove:
11) Error at end of compilation:
Code:
configmanager.cpp:(.text+0x181): undefined reference to `lua_getglobal'
/usr/bin/ld: CMakeFiles/tfs.dir/src/configmanager.cpp.o: in function `(anonymous namespace)::getGlobalBoolean(lua_State*, char const*, bool)':
configmanager.cpp:(.text+0x1fc): undefined reference to `lua_getglobal'
(...)
/usr/bin/ld: CMakeFiles/tfs.dir/src/databasemanager.cpp.o: in function `DatabaseManager::updateDatabase()':
databasemanager.cpp:(.text+0x98c): undefined reference to `lua_setglobal'
Install LuaJIT:
Code:
apt install libluajit-5.1-dev
Replace
cmake/FindLuaJIT.cmake file with newest TFS one:
https://github.com/otland/forgottenserver/blob/master/cmake/FindLuaJIT.cmake
12) Error:
Code:
databasemysql.cpp: In constructor ‘DatabaseMySQL::DatabaseMySQL()’:
databasemysql.cpp:47:2: error: ‘my_bool’ was not declared in this scope; did you mean ‘bool’?
47 | my_bool reconnect = true;
Replace in
databasemysql.cpp:
Code:
my_bool reconnect = true;
With:
13) Error:
Code:
otserv.cpp: In function ‘void otserv(StringVec, ServiceManager*)’:
otserv.cpp:599:18: error: invalid use of incomplete type ‘RSA’ {aka ‘struct rsa_st’}
BN_dec2bn(&g_RSA->p, g_config.getString(ConfigManager::RSA_PRIME1).c_str());
^~
In file included from /usr/include/openssl/crypto.h:25,
from /usr/include/openssl/bio.h:20,
from /usr/include/openssl/asn1.h:16,
from /usr/include/openssl/rsa.h:16,
from otserv.cpp:44:
/usr/include/openssl/ossl_typ.h:110:16: note: forward declaration of ‘RSA’ {aka ‘struct rsa_st’}
typedef struct rsa_st RSA;
You must replace outdated OpenSSL library with Crypto++ and GMP libraries.
Example of replacing libraries and algorithms RSA, MD5, SHA1, SHA256, SHA512 with RSA and SHA1 (other algorithms removed) in OTX2 engine:
… RSA and SHA1
github.com
14) Error:
Code:
talkaction.cpp:248:15: note: ‘std::__cxx11::basic_stringstream<char>’ is not derived from ‘std::_Setfill<_CharT>’
248 | ss << sl << "...";
talkaction.cpp:248:15: note: cannot convert ‘sl’ (type ‘std::stringstream’ {aka ‘std::__cxx11::basic_stringstream<char>’}) to type ‘std::_Setprecision’
248 | ss << sl << "...";
talkaction.cpp:247:15: error: cannot bind ‘std::basic_ostream<char>’ lvalue to ‘std::basic_ostream<char>&&’
ss << sl << "...";
Replace in
talkaction.cpp:
With:
15) Error:
Code:
‘lexical_cast’ is not a member of ‘boost’
creatureevent.cpp: In member function ‘bool CreatureEvents::playerLogout(Player*, bool)’:
creatureevent.cpp:146:38: error: ‘lexical_cast’ is not a member of ‘boost’
player->setStorage(expPots, boost::lexical_cast<std::string>(expPotCharges));
^~~~~~~~~~~~
creatureevent.cpp:146:38: note: suggested alternative: ‘numeric_cast’
player->setStorage(expPots, boost::lexical_cast<std::string>(expPotCharges));
^~~~~~~~~~~~
numeric_cast
creatureevent.cpp:146:62: error: expected primary-expression before ‘>’ token
player->setStorage(expPots, boost::lexical_cast<std::string>(expPotCharges));
At top of file - in this case
creatureevent.cpp , but it can be reported in other files too - add:
Code:
#include <boost/lexical_cast.hpp>
16) Error:
Code:
talkaction.cpp: In member function ‘bool TalkActions::onPlayerSay(Creature*, uint16_t, const string&, bool)’:
talkaction.cpp:137:37: error: array must be initialized with a brace-enclosed initializer
137 | std::string cmdstring[TALKFILTER_LAST] = words, param[TALKFILTER_LAST] = "";
| ^~~~~
talkaction.cpp:137:69: error: array must be initialized with a brace-enclosed initializer
137 | std::string cmdstring[TALKFILTER_LAST] = words, paramstring[TALKFILTER_LAST] = "";
Replace in
talkaction.cpp:
Code:
std::string cmdstring[TALKFILTER_LAST] = words, paramstring[TALKFILTER_LAST] = "";
With:
Code:
std::string cmdstring[TALKFILTER_LAST] = {words, words, words}, paramstring[TALKFILTER_LAST] = {"", "", ""};
To apply all changes, you MUST run all 3 commands again:
Code:
sh autogen.sh
./configure --enable-mysql --disable-dependency-tracking
sh build.sh
If you get any compilation error not listed above, post it in this thread.
(only problems with compiling old OTS engines on Debian 9 / 10 and Ubuntu 20.04)
You can also send errors to me by
Discord:
Gesior.pl#3208