• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Linux Compile OTSERVER - Debian 9

fyalhed

Member
Joined
Nov 18, 2017
Messages
156
Reaction score
20
I did compile OtServer to Debian 9, using @Shyzoul tutorial:
Code:
apt-get install autoconf build-essential pkg-config automake libboost-all-dev libgmp3-dev libxml2-dev liblua5.1-0-dev libssl-dev libsqlite3-dev
apt-get install default-libmysqlclient-dev

Changing make file to: hastebin

So make, and did compile withtout errors

But when i try to open the server:
Code:
./theforgottenserver
./theforgottenserver: error while loading shared libraries: libmysqlclient.so.20: cannot open shared object file: No such file or directory
 
I did compile OtServer to Debian 9, using @Shyzoul tutorial:
remove default-libmysqlclient-dev and install libmariadbclient-dev instead, also replace your makefile, it was just a test, i've updated it because this let make do its job, which is recompile only files that needs to be recompiled you can compile faster in parallel with -j, e.g make -j`nproc`
Code:
SRC = actions.cpp admin.cpp allocator.cpp baseevents.cpp beds.cpp chat.cpp\
      combat.cpp condition.cpp configmanager.cpp connection.cpp container.cpp\
      creature.cpp creatureevent.cpp cylinder.cpp database.cpp\
      databasemanager.cpp databasemysql.cpp databasesqlite.cpp depot.cpp\
      dispatcher.cpp exception.cpp fileloader.cpp game.cpp gameservers.cpp\
      globalevent.cpp group.cpp house.cpp housetile.cpp ioban.cpp ioguild.cpp\
      iologindata.cpp iomap.cpp iomapserialize.cpp itemattributes.cpp item.cpp\
      items.cpp luascript.cpp mailbox.cpp manager.cpp map.cpp monster.cpp\
      monsters.cpp movement.cpp networkmessage.cpp npc.cpp otserv.cpp\
      outfit.cpp outputmessage.cpp party.cpp player.cpp position.cpp\
      protocol.cpp protocolgame.cpp protocolhttp.cpp protocollogin.cpp\
      protocolold.cpp quests.cpp raids.cpp rsa.cpp scheduler.cpp\
      scriptmanager.cpp server.cpp spawn.cpp spells.cpp status.cpp\
      talkaction.cpp teleport.cpp textlogger.cpp thing.cpp tile.cpp tools.cpp\
      trashholder.cpp vocation.cpp waitlist.cpp weapons.cpp

OBJ = ${SRC:.cpp=.o}

CC = g++
INCS = -I/usr/include/libxml2 -I/usr/include/lua5.1 -I. 
CPPFLAGS = -DHAVE_CONFIG_H -D__USE_MYSQL__ -D__ENABLE_SERVER_DIAGNOSTIC__ -D__ROOT_PERMISSION__ -D_THREAD_SAFE -D_REENTRANT
CXXFLAGS = -std=c++03 -Os -fomit-frame-pointer -Wall -Wextra -Wno-strict-aliasing -Wno-unused-parameter -Wno-array-bounds -pipe ${INCS} ${CPPFLAGS}
LDFLAGS = -s -llua5.1 -lmariadbclient -lcrypto -lboost_filesystem -lboost_date_time -lboost_system -lboost_regex -lboost_thread -lz -lgmp -lxml2 -pthread
all: options tfs

options:
    @echo tfs build options:
    @echo "CXXFLAGS = ${CXXFLAGS}"
    @echo "LDFLAGS  = ${LDFLAGS}"
    @echo "CC       = ${CC}"

.cpp.o:
    @echo '${CC} $<'
    @${CC} -c ${CXXFLAGS} $<

tfs: ${OBJ}
    @echo CC -o $@
    @${CC} -o $@ ${OBJ} ${LDFLAGS}

clean:
    @echo cleaning
    @rm -f tfs ${OBJ}

.PHONY: all clean options
 
remove default-libmysqlclient-dev and install libmariadbclient-dev instead, also replace your makefile, it was just a test, i've updated it because this let make do its job, which is recompile only files that needs to be recompiled you can compile faster in parallel with -j, e.g make -j`nproc`
Code:
SRC = actions.cpp admin.cpp allocator.cpp baseevents.cpp beds.cpp chat.cpp\
      combat.cpp condition.cpp configmanager.cpp connection.cpp container.cpp\
      creature.cpp creatureevent.cpp cylinder.cpp database.cpp\
      databasemanager.cpp databasemysql.cpp databasesqlite.cpp depot.cpp\
      dispatcher.cpp exception.cpp fileloader.cpp game.cpp gameservers.cpp\
      globalevent.cpp group.cpp house.cpp housetile.cpp ioban.cpp ioguild.cpp\
      iologindata.cpp iomap.cpp iomapserialize.cpp itemattributes.cpp item.cpp\
      items.cpp luascript.cpp mailbox.cpp manager.cpp map.cpp monster.cpp\
      monsters.cpp movement.cpp networkmessage.cpp npc.cpp otserv.cpp\
      outfit.cpp outputmessage.cpp party.cpp player.cpp position.cpp\
      protocol.cpp protocolgame.cpp protocolhttp.cpp protocollogin.cpp\
      protocolold.cpp quests.cpp raids.cpp rsa.cpp scheduler.cpp\
      scriptmanager.cpp server.cpp spawn.cpp spells.cpp status.cpp\
      talkaction.cpp teleport.cpp textlogger.cpp thing.cpp tile.cpp tools.cpp\
      trashholder.cpp vocation.cpp waitlist.cpp weapons.cpp

OBJ = ${SRC:.cpp=.o}

CC = g++
INCS = -I/usr/include/libxml2 -I/usr/include/lua5.1 -I.
CPPFLAGS = -DHAVE_CONFIG_H -D__USE_MYSQL__ -D__ENABLE_SERVER_DIAGNOSTIC__ -D__ROOT_PERMISSION__ -D_THREAD_SAFE -D_REENTRANT
CXXFLAGS = -std=c++03 -Os -fomit-frame-pointer -Wall -Wextra -Wno-strict-aliasing -Wno-unused-parameter -Wno-array-bounds -pipe ${INCS} ${CPPFLAGS}
LDFLAGS = -s -llua5.1 -lmariadbclient -lcrypto -lboost_filesystem -lboost_date_time -lboost_system -lboost_regex -lboost_thread -lz -lgmp -lxml2 -pthread
all: options tfs

options:
    @echo tfs build options:
    @echo "CXXFLAGS = ${CXXFLAGS}"
    @echo "LDFLAGS  = ${LDFLAGS}"
    @echo "CC       = ${CC}"

.cpp.o:
    @echo '${CC} $<'
    @${CC} -c ${CXXFLAGS} $<

tfs: ${OBJ}
    @echo CC -o $@
    @${CC} -o $@ ${OBJ} ${LDFLAGS}

clean:
    @echo cleaning
    @rm -f tfs ${OBJ}

.PHONY: all clean options

Thank you to help :)

I did what u said, but when i try to compile show me this:
make -j`nproc`
Makefile:28: *** missing separator. Stop.

What is wrong on line 28 (@Echo "CXXFLAGS = ${CXXFLAGS}")?
 
What is wrong on line 28 (@Echo "CXXFLAGS = ${CXXFLAGS}")?
have you copied from Windows? i think its fault of windows line ending, try converting your file to unix line endings, you can do that by using an editor that supports unix line endings on windows, or running on linux tools such as dos2unix <filename>.
 
have you copied from Windows? i think its fault of windows line ending, try converting your file to unix line endings, you can do that by using an editor that supports unix line endings on windows, or running on linux tools such as dos2unix <filename>.

What are u mean? I do not use Windows...
 
i see the problem, forum is replacing tabs to spaces, make are space sensible, replace spaces in beginning of line to tabs from line 28 to EOF otherwise get it from here hastebin

Now is starting the compiler, but it's not compiling
Code:
make -j`nproc`
tfs build options:
g++ admin.cpp
CXXFLAGS = -std=c++03 -Os -fomit-frame-pointer -Wall -Wextra -Wno-strict-aliasing -Wno-unused-parameter -Wno-array-bounds -pipe -I/usr/include/libxml2 -I/usr/include/lua5.1 -I.   -DHAVE_CONFIG_H -D__USE_MYSQL__ -D__ENABLE_SERVER_DIAGNOSTIC__ -D__ROOT_PERMISSION__ -D_THREAD_SAFE -D_REENTRANT
g++ gameservers.cpp
LDFLAGS  = -s -llua5.1 -lmariadbclient -lcrypto -lboost_filesystem -lboost_date_time -lboost_system -lboost_regex -lboost_thread -lz -lgmp -lxml2 -pthread
g++ player.cpp
CC       = g++
g++ protocolgame.cpp
g++ weapons.cpp
protocolgame.cpp: In member function ‘void ProtocolGame::AddCreatureSpeak(NetworkMessage_ptr, const Creature*, SpeakClasses, std::__cxx11::string, uint16_t, uint32_t, Position*, ProtocolGame*)’:
protocolgame.cpp:2971:137: warning: suggest parentheses around ‘&&’ within ‘||’ [-Wparentheses]
 Manager()) && (!speaker->hasCustomFlag(PlayerCustomFlag_HideLevel)) && ((pg == NULL)) || ((pg != NULL) && (!pg->getIsCast()))))
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
CC -o tfs
items.o: file not recognized: File truncated
collect2: error: ld returned 1 exit status
Makefile:37: recipe for target 'tfs' failed
make: *** [tfs] Error 1
 
this generally happens when you force an exit while compiling running, then corruptions on files will likely happen, try 'make clean' and then 'make' again
Oh ty, i didn't know that...

Now back to compile fine:
make -j`nproc`
Code:
tfs build options:
g++ actions.cpp
g++ allocator.cpp
CXXFLAGS = -std=c++03 -Os -fomit-frame-pointer -Wall -Wextra -Wno-strict-aliasing -Wno-unused-parameter -Wno-array-bounds -pipe -I/usr/include/libxml2 -I/usr/include/lua5.1 -I.   -DHAVE_CONFIG_H -D__USE_MYSQL__ -D__ENABLE_SERVER_DIAGNOSTIC__ -D__ROOT_PERMISSION__ -D_THREAD_SAFE -D_REENTRANT
g++ admin.cpp
LDFLAGS  = -s -llua5.1 -lmariadbclient -lcrypto -lboost_filesystem -lboost_date_time -lboost_system -lboost_regex -lboost_thread -lz -lgmp -lxml2 -pthread
CC       = g++
g++ baseevents.cpp
g++ beds.cpp
g++ chat.cpp
g++ combat.cpp
g++ condition.cpp
g++ configmanager.cpp
g++ connection.cpp
g++ container.cpp
g++ creature.cpp
g++ creatureevent.cpp
g++ cylinder.cpp
g++ database.cpp
g++ databasemanager.cpp
g++ databasemysql.cpp
g++ databasesqlite.cpp
g++ depot.cpp
g++ dispatcher.cpp
g++ exception.cpp
g++ fileloader.cpp
g++ game.cpp
g++ gameservers.cpp
g++ globalevent.cpp
g++ group.cpp
g++ house.cpp
game.cpp: In constructor ‘Game::Game()’:
game.cpp:80:24: warning: iteration 2 invokes undefined behavior [-Waggressive-loop-optimizations]
   globalSaveMessage[i] = false;
   ~~~~~~~~~~~~~~~~~~~~~^~~~~~~
game.cpp:79:23: note: within this loop
  for(int16_t i = 0; i < 3; i++)
                     ~~^~~
In file included from game.cpp:18:0:
game.h: In member function ‘void Game::globalSave()’:
game.h:616:78: warning: iteration 2 invokes undefined behavior [-Waggressive-loop-optimizations]
   void setGlobalSaveMessage(int16_t key, bool value) {globalSaveMessage[key] = value;}
                                                       ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~
game.cpp:6340:23: note: within this loop
  for(int16_t i = 0; i < 3; i++)
                     ~~^~~
g++ housetile.cpp
g++ ioban.cpp
g++ ioguild.cpp
g++ iologindata.cpp
g++ iomap.cpp
g++ iomapserialize.cpp
g++ itemattributes.cpp
g++ item.cpp
g++ items.cpp
g++ luascript.cpp
g++ mailbox.cpp
g++ manager.cpp
g++ map.cpp
g++ monster.cpp
monster.cpp: In member function ‘bool Monster::isFriend(const Creature*)’:
monster.cpp:315:5: warning: this ‘if’ clause does not guard... [-Wmisleading-indentation]
     if(creature->getPlayer() && !targetPlayers)
     ^~
monster.cpp:318:2: note: ...this statement, but the latter is misleadingly indented as if it is guarded by the ‘if’
  if(!isSummon() || !master->getPlayer())
  ^~
monster.cpp: In member function ‘bool Monster::isOpponent(const Creature*)’:
monster.cpp:338:5: warning: this ‘if’ clause does not guard... [-Wmisleading-indentation]
     if(creature->getPlayer() && !targetPlayers)
     ^~
monster.cpp:341:2: note: ...this statement, but the latter is misleadingly indented as if it is guarded by the ‘if’
  return (isSummon() && master->getPlayer() && creature != master) || ((creature->getPlayer()
  ^~~~~~
g++ monsters.cpp
g++ movement.cpp
g++ networkmessage.cpp
g++ npc.cpp
g++ otserv.cpp
g++ outfit.cpp
g++ outputmessage.cpp
g++ party.cpp
g++ player.cpp
g++ position.cpp
g++ protocol.cpp
g++ protocolgame.cpp
g++ protocolhttp.cpp
protocolgame.cpp: In member function ‘void ProtocolGame::AddCreatureSpeak(NetworkMessage_ptr, const Creature*, SpeakClasses, std::__cxx11::string, uint16_t, uint32_t, Position*, ProtocolGame*)’:
protocolgame.cpp:2971:137: warning: suggest parentheses around ‘&&’ within ‘||’ [-Wparentheses]
   if((speaker && (type != SPEAK_RVR_ANSWER ) && (!speaker->isAccountManager()) && (!speaker->hasCustomFlag(PlayerCustomFlag_HideLevel)) && ((pg == NULL)) || ((pg != NULL) && (!pg->getIsCast()))))
       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
g++ protocollogin.cpp
g++ protocolold.cpp
g++ quests.cpp
g++ raids.cpp
g++ rsa.cpp
g++ scheduler.cpp
g++ scriptmanager.cpp
g++ server.cpp
g++ spawn.cpp
g++ spells.cpp
g++ status.cpp
g++ talkaction.cpp
g++ teleport.cpp
g++ textlogger.cpp
g++ thing.cpp
g++ tile.cpp
g++ tools.cpp
g++ trashholder.cpp
g++ vocation.cpp
g++ waitlist.cpp
g++ weapons.cpp
CC -o tfs

But again when i try to open the server:
Code:
./theforgottenserver
./theforgottenserver: error while loading shared libraries: libmysqlclient.so.20: cannot open shared object file: No such file or directory
 
But again when i try to open the server:
that is weird, on all my debian (x86_64) machines it just works, this will fix your problem, '#ln -sf /usr/lib/x86_64-linux-gnu/libmariadbclient.so /usr/lib/x86_64-linux-gnu/libmysqlclient.so.20' (notice that the prefix "x86_64" may be different depending in your debian version), tho i'm curious about why it's happening, can you tell me the output of readelf -d /path/to/tfsbin, also 'file /usr/lib/x86_64-linux-gnu/libmariadbclient.so'
 
Thank you @Shyzoul so much!
U said that was strange, i re-dowload my source pack and compile fine, u was right...

For anybody else who need to compile in debian 9, the steps are (using him makefile):
apt-get install autoconf build-essential pkg-config automake libboost-all-dev libgmp3-dev libxml2-dev liblua5.1-0-dev libssl-dev libsqlite3-dev
apt-get install libmariadbclient-dev
make -j`nproc`
 
Wut? You're necrobumping a 3 year old thread over how to install the toolchain headers for the most common database in the world?

😕
 
Back
Top