Ir para conteúdo
Propaganda

[C++/Linux] Compilando engine antiga (sources) no Debian 10 / Ubuntu 20.04


Posts Recomendados

  • Administrador

Salve rapaziada, mais um tutorial ai. ensinando a adaptar as sources antigas pra poder compilar no debian 10+ e ubuntu 20+

 

Primeiramente, vamos instalar os pacotes para compilar no Debian 10 (No ubuntu também funciona)

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

Comando para compilar

sh autogen.sh
./configure --enable-mysql
sh build.sh

Agora vamos ao passo a passo de como corrigir os erros 1 por 1

Primeiramente, baixe algum programa para pesquisar em todos os arquivos no diretório 'sources', como Notepad ++/Sublime Text, algum IDE ou no caso do terminal linux "grep -R"

1° erro

Spoiler
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."

Pesquise em todos os arquivos no diretório 'sources'. Substitua cada

/tr1/

Por

/

Substitua cada

std::tr1::

Por

boost::

 

2° erro

Spoiler
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;

substitua na linha 1144 - está na função "ChatChannel* Chat::getChannel(Player*, uint16_t)" - do chat.cpp:

return false;

Por

return NULL;

 

3° erro

Spoiler
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)

Nos arquivos connection.cpp e connection.h (Algumas pesquisas podem retornar 0 resultados, tudo bem.)

Substitua cada

Connection::readTimeout

Por

CONNECTION_READ_TIMEOUT

Substitua cada

Connection::writeTimeout

Por

CONNECTION_WRITE_TIMEOUT

Substitua cada

Connection::read_timeout

Por

CONNECTION_READ_TIMEOUT

Substitua cada

Connection::write_timeout

Por

CONNECTION_WRITE_TIMEOUT

Em connection.h remova

enum {writeTimeout = 30};
enum {readTimeout = 30};

Em connection.h, abaixo de 

class Protocol;

Adicione

static constexpr int32_t CONNECTION_WRITE_TIMEOUT = 30;
static constexpr int32_t CONNECTION_READ_TIMEOUT = 30;

 

4° erro

Spoiler
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;

substitua na linha 1725 - está na função "Item* Game::findItemOfType(Cylinder*, uint16_t, bool, int32_t)" - de game.cpp:

return false;

Por

return NULL;

 

5° erro

Spoiler
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();

Em luascript.cpp, substitua cada

->leaf()

Por

->path().filename().string()

 

6° erro

Spoiler
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;

Ou 

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;

Em protocolgame.cpp substitua

s << player->getName() << " sent unknown byte: " << hex << std::endl;

Por

s << player->getName() << " sent unknown byte: " << hex.str() << std::endl;

 

7° erro

Spoiler
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();

Em scriptmanager.cpp substitua cada

->leaf()

Por

->path().filename().string()

 

8° erro

Spoiler
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] = "";

Em talkaction.cpp substitua

std::string cmd[TALKFILTER_LAST] = words, param[TALKFILTER_LAST] = "";

Por

std::string cmd[TALKFILTER_LAST] = {words, words, words}, param[TALKFILTER_LAST] = {"", "", ""};

 

9° erro no final da compilação

Spoiler
/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

Em configure.ac substitua

LIBS="$LIBS $XML_LIBS"

Por

LIBS="$LIBS $XML_LIBS -lpthread"

 

10° Erros aleatórios de C++ - avisos tratados como erros devido à configuração.

Antes de começar a pesquisar no fórum, por que ele não compila, edite o arquivo makefile.am:

Procure e remova

-Wall
-Wextra
-Werror

11° erro no final da compilação

Spoiler
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'

Instale o luaJit

apt install libluajit-5.1-dev

Substitua o arquivo cmake/FindLuaJIT.cmake pelo mais novo arquivo TFS:

This is the hidden content, please

12° erro

Spoiler
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;

Em databasemysql.cpp substitua

my_bool reconnect = true;

Por

bool reconnect = true;

 

13° erro

Spoiler
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;

Você deve substituir a biblioteca OpenSSL desatualizada pelas bibliotecas Crypto++ e GMP. Exemplo de substituição de bibliotecas e algoritmos RSA, MD5, SHA1, SHA256, SHA512 por RSA e SHA1 (outros algoritmos removidos) no mecanismo OTX2:

This is the hidden content, please

14° erro

Spoiler
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 << "...";

Em talkaction.cpp substitua

ss << sl << "...";

Por

ss << sl.str() << "...";

 

15° erro

Spoiler
‘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));

No topo do arquivo - neste caso, o creatureevent.cpp , mas também pode dar o erro em outros arquivos - adicione:

#include <boost/lexical_cast.hpp>

16° erro

Spoiler
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] = "";

Substitua em talkaction.cpp

std::string cmdstring[TALKFILTER_LAST] = words, paramstring[TALKFILTER_LAST] = "";

Por

std::string cmdstring[TALKFILTER_LAST] = {words, words, words}, paramstring[TALKFILTER_LAST] = {"", "", ""};

 

Feito tudo isso, podemos rodar o comando novamente

sh autogen.sh
./configure --enable-mysql
sh build.sh

 

Créditos: 100% Gesior - 

This is the hidden content, please

  • Like 15
  • Thanks 3
  • Confused 1
Link para o comentário
https://tibiadevs.com/forums/topic/30-clinux-compilando-engine-antiga-sources-no-debian-10-ubuntu-2004/
Compartilhar em outros sites

  • Administrador
5 minutos atrás, gutinha disse:

Salve rapaziada, mais um tutorial ai. ensinando a adaptar as sources antigas pra poder compilar no debian 10+ e ubuntu 20+

 

Primeiramente, vamos instalar os pacotes para compilar no Debian 10 (No ubuntu também funciona)

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

Comando para compilar

sh autogen.sh
./configure --enable-mysql
sh build.sh

Agora vamos ao passo a passo de como corrigir os erros 1 por 1

Primeiramente, baixe algum programa para pesquisar em todos os arquivos no diretório 'sources', como Notepad ++/Sublime Text, algum IDE ou no caso do terminal linux "grep -R"

1° erro

  Mostrar conteúdo oculto
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."

Pesquise em todos os arquivos no diretório 'sources'. Substitua cada

/tr1/

Por

/

Substitua cada

std::tr1::

Por

boost::

 

2° erro

  Mostrar conteúdo oculto
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;

substitua na linha 1144 - está na função "ChatChannel* Chat::getChannel(Player*, uint16_t)" - do chat.cpp:

return false;

Por

return NULL;

 

3° erro

  Mostrar conteúdo oculto
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)

Nos arquivos connection.cpp e connection.h (Algumas pesquisas podem retornar 0 resultados, tudo bem.)

Substitua cada

Connection::readTimeout

Por

CONNECTION_READ_TIMEOUT

Substitua cada

Connection::writeTimeout

Por

CONNECTION_WRITE_TIMEOUT

Substitua cada

Connection::read_timeout

Por

CONNECTION_READ_TIMEOUT

Substitua cada

Connection::write_timeout

Por

CONNECTION_WRITE_TIMEOUT

Em connection.h remova

enum {writeTimeout = 30};
enum {readTimeout = 30};

Em connection.h, abaixo de 

class Protocol;

Adicione

static constexpr int32_t CONNECTION_WRITE_TIMEOUT = 30;
static constexpr int32_t CONNECTION_READ_TIMEOUT = 30;

 

4° erro

  Mostrar conteúdo oculto
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;

substitua na linha 1725 - está na função "Item* Game::findItemOfType(Cylinder*, uint16_t, bool, int32_t)" - de game.cpp:

return false;

Por

return NULL;

 

5° erro

  Mostrar conteúdo oculto
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();

Em luascript.cpp, substitua cada

->leaf()

Por

->path().filename().string()

 

6° erro

  Mostrar conteúdo oculto
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;

Ou 

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;

Em protocolgame.cpp substitua

s << player->getName() << " sent unknown byte: " << hex << std::endl;

Por

s << player->getName() << " sent unknown byte: " << hex.str() << std::endl;

 

7° erro

  Mostrar conteúdo oculto
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();

Em scriptmanager.cpp substitua cada

->leaf()

Por

->path().filename().string()

 

8° erro

  Mostrar conteúdo oculto
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] = "";

Em talkaction.cpp substitua

std::string cmd[TALKFILTER_LAST] = words, param[TALKFILTER_LAST] = "";

Por

std::string cmd[TALKFILTER_LAST] = {words, words, words}, param[TALKFILTER_LAST] = {"", "", ""};

 

9° erro no final da compilação

  Mostrar conteúdo oculto
/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

Em configure.ac substitua

LIBS="$LIBS $XML_LIBS"

Por

LIBS="$LIBS $XML_LIBS -lpthread"

 

10° Erros aleatórios de C++ - avisos tratados como erros devido à configuração.

Antes de começar a pesquisar no fórum, por que ele não compila, edite o arquivo makefile.am:

Procure e remova

-Wall
-Wextra
-Werror

11° erro no final da compilação

  Mostrar conteúdo oculto
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'

Instale o luaJit

apt install libluajit-5.1-dev

Substitua o arquivo cmake/FindLuaJIT.cmake pelo mais novo arquivo TFS:

This is the hidden content, please

12° erro

  Mostrar conteúdo oculto
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;

Em databasemysql.cpp substitua

my_bool reconnect = true;

Por

bool reconnect = true;

 

13° erro

  Mostrar conteúdo oculto
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;

Você deve substituir a biblioteca OpenSSL desatualizada pelas bibliotecas Crypto++ e GMP. Exemplo de substituição de bibliotecas e algoritmos RSA, MD5, SHA1, SHA256, SHA512 por RSA e SHA1 (outros algoritmos removidos) no mecanismo OTX2:

This is the hidden content, please

14° erro

  Mostrar conteúdo oculto
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 << "...";

Em talkaction.cpp substitua

ss << sl << "...";

Por

ss << sl.str() << "...";

 

15° erro

  Mostrar conteúdo oculto
‘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));

No topo do arquivo - neste caso, o creatureevent.cpp , mas também pode dar o erro em outros arquivos - adicione:

#include <boost/lexical_cast.hpp>

16° erro

  Mostrar conteúdo oculto
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] = "";

Substitua em talkaction.cpp

std::string cmdstring[TALKFILTER_LAST] = words, paramstring[TALKFILTER_LAST] = "";

Por

std::string cmdstring[TALKFILTER_LAST] = {words, words, words}, paramstring[TALKFILTER_LAST] = {"", "", ""};

 

Feito tudo isso, podemos rodar o comando novamente

sh autogen.sh
./configure --enable-mysql
sh build.sh

 

Créditos: 100% Gesior - 

This is the hidden content, please

Obrigado por contribuir 🚀

  • Like 1
  • Thanks 1
Link para o comentário
https://tibiadevs.com/forums/topic/30-clinux-compilando-engine-antiga-sources-no-debian-10-ubuntu-2004/#findComment-159
Compartilhar em outros sites

  • 2 meses depois...

Crie uma conta ou entre para comentar

Você precisar ser um membro para fazer um comentário

Criar uma conta

Crie uma nova conta em nossa comunidade. É fácil!

Crie uma nova conta

Entrar

Já tem uma conta? Faça o login.

Entrar Agora
×
  • Criar Novo...