Ezzz-dev / Nostalrius

Nostalrius is a 7.7 Tibia Clone Project based on The Forgotten Server 1.2 and CipSoft files.
100 stars 72 forks source link

Compiling errors in behaviourdatabase.cpp #34

Open fschuindt opened 5 years ago

fschuindt commented 5 years ago

Hello there!

I'm trying to compile it in Linux, got this error after running make:

-- The C compiler identification is GNU 8.2.0
-- The CXX compiler identification is GNU 8.2.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- cotire 1.7.6 loaded.
-- Performing Test COMPILER_KNOWS_CXX11
-- Performing Test COMPILER_KNOWS_CXX11 - Success
-- Performing Test COMPILER_KNOWS_STDLIB
-- Performing Test COMPILER_KNOWS_STDLIB - Failed
-- Found GMP: /usr/include  
-- Found PugiXML: /usr/include  
-- Could NOT find LuaJIT (missing: LUA_LIBRARIES LUA_INCLUDE_DIR) 
-- MySQL Include dir: /usr/include/mysql  library dir: /usr/lib
-- MySQL client libraries: mysqlclient
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - found
-- Found Threads: TRUE  
-- Found Lua: /usr/lib/liblua.so;/usr/lib/libm.a (found version "5.1.5") 
-- Boost version: 1.67.0
-- Found the following Boost libraries:
--   system
--   filesystem
-- CXX target tfs cotired without unity build.
-- Configuring done
-- Generating done
-- Build files have been written to: /otserv/build
/otserv/build # make
[  1%] Generating CXX prefix source cotire/tfs_CXX_prefix.cxx
[  2%] Generating CXX prefix header cotire/tfs_CXX_prefix.hxx
[  4%] Building CXX precompiled header cotire/tfs_CXX_prefix.hxx.gch
Scanning dependencies of target tfs
[  5%] Building CXX object CMakeFiles/tfs.dir/src/otpch.cpp.o
[  7%] Building CXX object CMakeFiles/tfs.dir/src/actions.cpp.o
[  8%] Building CXX object CMakeFiles/tfs.dir/src/ban.cpp.o
[  9%] Building CXX object CMakeFiles/tfs.dir/src/baseevents.cpp.o
[ 11%] Building CXX object CMakeFiles/tfs.dir/src/bed.cpp.o
[ 12%] Building CXX object CMakeFiles/tfs.dir/src/behaviourdatabase.cpp.o
/otserv/src/behaviourdatabase.cpp: In member function 'int32_t BehaviourDatabase::searchDigit(const string&)':
/otserv/src/behaviourdatabase.cpp:1150:14: error: catching polymorphic type 'class std::invalid_argument' by value [-Werror=catch-value=]
  catch (std::invalid_argument) {
              ^~~~~~~~~~~~~~~~
/otserv/src/behaviourdatabase.cpp:1153:14: error: catching polymorphic type 'class std::out_of_range' by value [-Werror=catch-value=]
  catch (std::out_of_range) {
              ^~~~~~~~~~~~
cc1plus: all warnings being treated as errors
make[2]: *** [CMakeFiles/tfs.dir/build.make:147: CMakeFiles/tfs.dir/src/behaviourdatabase.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:105: CMakeFiles/tfs.dir/all] Error 2
make: *** [Makefile:84: all] Error 2

Any clue of what it might be? Thanks!

Steps to reproduce

I'm inside a Alpine Linux container. This is the Dockerfile:

FROM alpine:latest

COPY . /otserv/.

RUN apk update && \
    apk upgrade && \
    apk add --no-cache git make cmake gcc g++ boost-dev gmp-dev \
                       mariadb-dev lua-dev pugixml-dev

EXPOSE 7171

Then I performed the commands:

mkdir build
cd build
cmake ..
make
Ezzz-dev commented 5 years ago

Can't say for certain but it seems the issue to be related to GCC 8+, consider removing the "werror" flag from the cmakelists files and try to compile once more.

fschuindt commented 5 years ago

@TwistedScorpio Thanks! That allowed me to compile it. But I saw some warnings. Which GCC version you recommend to use?

mikhael4ever commented 5 years ago

@TwistedScorpio Thanks! That allowed me to compile it. But I saw some warnings. Which GCC version you recommend to use?

Yeah the same here.