• 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 Compiling issue in Linux

Mjmackan

Mapper ~ Writer
Joined
Jul 18, 2009
Messages
1,434
Solutions
15
Reaction score
179
Location
Sweden
Heyo, trying to compile some sources, works fine in Windows but getting warnings in Linux which stops me from continueing.

TFS version 1.4.1 vc14
Sucessfull compiling on: Windows 10
Non successfull compile on: Linux Ubuntu 24.04.1

Some things I've ticked:
-The command Wno-dev wont do any.
-There's no such thing as 'Werror' in my CMakeFiles.
-Updated libraries.
-Reinstalled server.
-Makefile:91 contains line: .PHONY : clean/fast
-Makefile2:102 contains line: $(MAKE) $(MAKESILENT) -f CMakeFiles/tfs.dir/build.make CMakeFiles/tfs.dir/build
-build.make:109 contains line: /usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -Winvalid-pch -include /home/otsmanager/forgottenserver/build/CMakeFiles/tfs.dir/cmake_pch.hxx -MD -MT CMakeFiles/tfs.dir/src/actions.cpp.o -MF CMakeFiles/tfs.dir/src/actions.cpp.o.d -o CMakeFiles/tfs.dir/src/actions.cpp.o -c /home/otsmanager/forgottenserver/src/actions.cpp
-Correcting the warnings will give me errors instead, the fuck?

Code:
CMake Warning (dev) at src/CMakeLists.txt:1 (set):
  Cannot set "tfs_SRC": current scope has no parent.
Call Stack (most recent call first):
  CMakeLists.txt:104 (include)
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Configuring done (0.7s)
-- Generating done (0.0s)
-- Build files have been written to: /home/otsmanager/forgottenserver/build
otsmanager@gamefate:~/forgottenserver/build$ make
[  1%] Building CXX object CMakeFiles/tfs.dir/cmake_pch.hxx.gch
[  2%] Building CXX object CMakeFiles/tfs.dir/src/otpch.cpp.o
[  3%] Building CXX object CMakeFiles/tfs.dir/src/actions.cpp.o
In file included from /home/otsmanager/forgottenserver/src/game.h:30,
                 from /home/otsmanager/forgottenserver/src/actions.cpp:26:
/home/otsmanager/forgottenserver/src/player.h: In member function ‘void Player::setAttackSpeed(uint32_t)’:
/home/otsmanager/forgottenserver/src/player.h:1351:38: error: unused parameter ‘speed’ [-Werror=unused-parameter]
 1351 |         void setAttackSpeed(uint32_t speed) {
      |                             ~~~~~~~~~^~~~~
/home/otsmanager/forgottenserver/src/player.h: In member function ‘uint32_t Player::getAttackSpeed() const’:
/home/otsmanager/forgottenserver/src/player.h:1362:30: error: suggest parentheses around ‘&&’ within ‘||’ [-Werror=parentheses]
 1362 |         if (attackSpeed <= 0 && !weapon || attackSpeed <= 0 && weapon->getAttackSpeed() == 0) {
      |             ~~~~~~~~~~~~~~~~~^~~~~~~~~~
In file included from /home/otsmanager/forgottenserver/src/actions.cpp:28:
/home/otsmanager/forgottenserver/src/spells.h: At global scope:
/home/otsmanager/forgottenserver/src/spells.h:205:17: error: type qualifiers ignored on function return type [-Werror=ignored-qualifiers]
  205 |                 const SpellGroup_t getGroup() const {
      |                 ^~~~~
/home/otsmanager/forgottenserver/src/spells.h:211:17: error: type qualifiers ignored on function return type [-Werror=ignored-qualifiers]
  211 |                 const SpellGroup_t getSecondaryGroup() const {
      |                 ^~~~~
cc1plus: all warnings being treated as errors
make[2]: *** [CMakeFiles/tfs.dir/build.make:109: CMakeFiles/tfs.dir/src/actions.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:102: CMakeFiles/tfs.dir/all] Error 2
make: *** [Makefile:91: all] Error 2
 
-There's no such thing as 'Werror' in my CMakeFiles.
Official TFS 1.4 CMakeLists.txt line with Werror:
As you can see, it's disabled on Windows.

If you are using clean TFS 1.4 and want to compile it on Windows (Visual Studio 2022 + vcpkg; compile like TFS 1.6)/new Linuxes, you can use my updated version of TFS 1.4 (branch: compilation):
Changes:
  • OTS Stats
  • some optimizations from TFS 1.6
  • important bugs fixes from TFS 1.6
  • vcpkg.json added for VS2022 'vcpkg manifest: yes' compilation
 
can u share that cmake file? pretty sure youare looking for wrong one.
Here's the file:
LUA:
cmake_minimum_required(VERSION 3.10)

set(CMAKE_DISABLE_SOURCE_CHANGES ON)
set(CMAKE_DISABLE_IN_SOURCE_BUILD ON)

project(tfs)

add_subdirectory(src)
add_executable(tfs ${tfs_SRC})

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")

set_target_properties(tfs PROPERTIES CXX_STANDARD 17)
set_target_properties(tfs PROPERTIES CXX_STANDARD_REQUIRED ON)

if (NOT WIN32)
    add_compile_options(-Wall -Werror -pipe -fvisibility=hidden)
endif ()

set(CMAKE_CXX_FLAGS_PERFORMANCE "${CMAKE_CXX_FLAGS_RELEASE} -march=native")

if (CMAKE_COMPILER_IS_GNUCXX)
    add_compile_options(-fno-strict-aliasing)
endif ()

# Find packages.
find_package(CryptoPP QUIET)
if (CryptoPP_FOUND)  # vcpkg-provided cmake package called CryptoPP
    set(Crypto++_LIBRARIES "cryptopp-static")
else()
    find_package(Crypto++ REQUIRED)
endif ()
find_package(fmt 6.1.2 REQUIRED)

# Look for vcpkg-provided libmariadb first
# If we link to the file directly, we might miss its dependencies from vcpkg
find_package(unofficial-libmariadb CONFIG QUIET)
if (unofficial-libmariadb_FOUND)
    set(MYSQL_CLIENT_LIBS "libmariadb")
else ()
    find_package(MySQL REQUIRED)
endif ()

find_package(Threads REQUIRED)
find_package(PugiXML REQUIRED)

# Selects LuaJIT if user defines or auto-detected
if (DEFINED USE_LUAJIT AND NOT USE_LUAJIT)
    set(FORCE_LUAJIT ${USE_LUAJIT})
else ()
    find_package(LuaJIT)
    set(FORCE_LUAJIT ${LuaJIT_FOUND})
endif ()
option(USE_LUAJIT "Use LuaJIT" ${FORCE_LUAJIT})

if (FORCE_LUAJIT)
    if (APPLE)
        set(CMAKE_EXE_LINKER_FLAGS "-pagezero_size 10000 -image_base 100000000")
    endif ()
else ()
    find_package(Lua REQUIRED)
endif ()

find_package(Boost 1.66.0 REQUIRED COMPONENTS date_time system filesystem iostreams)

include_directories(${Boost_INCLUDE_DIRS} ${Crypto++_INCLUDE_DIR} ${LUA_INCLUDE_DIR} ${MYSQL_INCLUDE_DIR} ${PUGIXML_INCLUDE_DIR})
target_link_libraries(tfs PRIVATE
        Boost::date_time
        Boost::system
        Boost::filesystem
        Boost::iostreams
        fmt::fmt
        ${CMAKE_THREAD_LIBS_INIT}
        ${Crypto++_LIBRARIES}
        ${LUA_LIBRARIES}
        ${MYSQL_CLIENT_LIBS}
        ${PUGIXML_LIBRARIES}
        )

### INTERPROCEDURAL_OPTIMIZATION ###
cmake_policy(SET CMP0069 NEW)
include(CheckIPOSupported)
check_ipo_supported(RESULT result OUTPUT error)
if (result)
    message(STATUS "IPO / LTO enabled")
    set_target_properties(tfs PROPERTIES INTERPROCEDURAL_OPTIMIZATION True)
else ()
    message(STATUS "IPO / LTO not supported: <${error}>")
endif ()
### END INTERPROCEDURAL_OPTIMIZATION ###

### Git Version ###
# Define the two required variables before including
# the source code for watching a git repository.
option(SKIP_GIT "Skip checking for git updates" OFF)
if(NOT SKIP_GIT)
    set(PRE_CONFIGURE_FILE "cmake/gitmetadata.h.in")
    set(POST_CONFIGURE_FILE "${CMAKE_CURRENT_BINARY_DIR}/gitmetadata.h")
    include(git_watcher)
    if(Git_FOUND)
        add_dependencies(tfs check_git)
        target_include_directories(tfs PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
    endif()
endif()
### END  Git Version ###

# Precompiled header
# note: cotire() must be called last on a target
if (${CMAKE_VERSION} VERSION_GREATER "3.16.0")
    target_precompile_headers(tfs PUBLIC src/otpch.h)
else ()
    include(cotire)
    set_target_properties(tfs PROPERTIES COTIRE_CXX_PREFIX_HEADER_INIT "src/otpch.h")
    set_target_properties(tfs PROPERTIES COTIRE_ADD_UNITY_BUILD FALSE)
    cotire(tfs)
endif ()
Official TFS 1.4 CMakeLists.txt line with Werror:
As you can see, it's disabled on Windows.

If you are using clean TFS 1.4 and want to compile it on Windows (Visual Studio 2022 + vcpkg; compile like TFS 1.6)/new Linuxes, you can use my updated version of TFS 1.4 (branch: compilation):
Changes:
  • OTS Stats
  • some optimizations from TFS 1.6
  • important bugs fixes from TFS 1.6
  • vcpkg.json added for VS2022 'vcpkg manifest: yes' compilation
Its not clean, a lot of custom thingys, however I have compiled these exact sources before on Linux but I dont remember this being an issue back then.
 
however I have compiled these exact sources before on Linux
Linux Ubuntu 24.04.1
Maybe before you used older system? Ex. 20.04 or 22.04. Older linux versions have older C++ compiler versions, which detect/show less errors/warnings.
Here's the file:
In your file there is:
Code:
    add_compile_options(-Wall -Werror -pipe -fvisibility=hidden)
Replace it with:
Code:
    add_compile_options(-pipe -fvisibility=hidden)
and check, if it compiles.
 
Linux Ubuntu 24.04.1
Maybe before you used older system? Ex. 20.04 or 22.04. Older linux versions have older C++ compiler versions, which detect/show less errors/warnings.

In your file there is:
Code:
    add_compile_options(-Wall -Werror -pipe -fvisibility=hidden)
Replace it with:
Code:
    add_compile_options(-pipe -fvisibility=hidden)
and check, if it compiles.
Yeah ofcourse, thats it.
Would it help then compiling it in an older linux version and would i be able to run it in a newer Linux distro?

The edit you mentioned seems to make no difference to the outcome, tried to remove the line as well without any change.

I have forgot and failed when googleing it as well, but how do i make sure as for windows I have to direct it to the VC14 folder, I haven't set up that at all, but somehow it knows where src etc is located?? Maybe thats something Don do set as I am renting server from othosting.
 
VC14 folder
All that Linux uses is CMakeLists.txt and cmake to build TFS.
IDK, maybe try to remove build folder, create new and run all commands again, to make sure it detects CMakeLists.txt changes.
VC14 is project for Windows only (Visual Studio).
Would it help then compiling it in an older linux version and would i be able to run it in a newer Linux distro?
It's not super easy, but you can use Docker to run Ubuntu 20.04 on Ubuntu 24.04 (Linux-to-Linux is super easy and compatible on any Linux). All apps (website, database) will be 24.04, only OTS will use Ubuntu 20.04 to compile and run.

My edge case was to run Linux on Windows using Docker (WSL2 - Windows subsystem for Linux) with:
  • acc. maker, database, OTClient - Windows
  • server compile, server run - Ubuntu 24.04
and I use it everyday when I work on TFS.

EDIT:
Anyway, Ubuntu 20.04 has full support until April 2025 and 'security support' until April 2030, so you can use it on VPS/dedic to host OTS for years ( Ubuntu release cycle | Ubuntu (https://ubuntu.com/about/release-cycle) ).
 
IDK, maybe try to remove build folder, create new and run all commands again, to make sure it detects CMakeLists.txt changes.
VC14 is project for Windows only (Visual Studio).
I tried that as well, ah right i had totally forgotten that.
It's not super easy, but you can use Docker to run Ubuntu 20.04 on Ubuntu 24.04 (Linux-to-Linux is super easy and compatible on any Linux). All apps (website, database) will be 24.04, only OTS will use Ubuntu 20.04 to compile and run.
Not being super easy overall? Cause I am a total newbie when it comes to working with any OS overall.
It seems it might be easier to update the sources then, but good god so time consuming.
My edge case was to run Linux on Windows using Docker (WSL2 - Windows subsystem for Linux) with:
  • acc. maker, database, OTClient - Windows
  • server compile, server run - Ubuntu 24.04
and I use it everyday when I work on TFS.

EDIT:
Anyway, Ubuntu 20.04 has full support until April 2025 and 'security support' until April 2030, so you can use it on VPS/dedic to host OTS for years ( Ubuntu release cycle | Ubuntu (https://ubuntu.com/about/release-cycle) ).
Thats actually kinda cool, however then just downgrading OS might be the most efficient choice.

I have contacted Don as well to see if he struggled with this issue in any way, otherwise i might just put the server down and start moving to the new sources, if I'll ever get my arse to that point.
 
i use ubuntu 22 here is my configs for it : this will compile tfs 1.4.2 or 1.5 straight away without needing ANYTHING else.


Bash:
sudo apt update && sudo apt upgrade -y &&

sudo apt install nginx php-fpm mariadb-server -y &&

sudo apt install phpmyadmin -y &&

sudo apt-get install git cmake build-essential liblua5.2-dev libgmp3-dev libmysqlclient-dev libboost-system-dev libboost-iostreams-dev libboost-filesystem-dev libpugixml-dev libcrypto++-dev libfmt-dev libboost-date-time-dev

here is phpmyadmin setup:
Code:
nano /etc/nginx/sites-available/phpmyadmin
paste this WITHOUT // thats just BETWEEN symbol e.g everything between // //:
//
server {
    listen      2344;
    server_name  _;
    root /usr/share/phpmyadmin;

    add_header X-Frame-Options DENY;
    add_header X-Content-Type-Options nosniff;
    add_header X-XSS-Protection "1; mode=block";

    client_max_body_size 256M;
    error_page 404 @notfound;

    location / {
        index index.html index.php;
        try_files $uri $uri/ /index.php?$args;
    }

    location ~* \.(gif|jpg|jpeg|png|bmp|js|css)$ {
        expires max;
    }

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;

    ################## UBUNTU 22.04 LTS ##################
           fastcgi_pass unix:/var/run/php/php8.1-fpm.sock;
    ################## UBUNTU 20.04 LTS ##################
    #       fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;

    }

    location @notfound {
        return 404 "You're not browsing correctly.";
        add_header Content-Type text/plain always;
    }

}

//

run this:
sudo ln -s /etc/nginx/sites-available/phpmyadmin /etc/nginx/sites-enabled/phpmyadmin

sudo systemctl restart nginx

mariadb
create user 'otadmin'@'localhost' identified by 'YOURPASSWORD';
grant all privileges on *.* to 'otadmin'@'localhost';
flush privileges;
exit;


then go to IP:2344

here is also the default for sites available:


Code:
server {
        listen 80 default_server;
        listen [::]:80 default_server;

        root /home/html; 

        #var/www/html or ^

        # Add index.php to the list if you are using PHP
        index index.php index.html index.htm index.nginx-debian.html;

        server_name _;

        location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                try_files $uri $uri/ =404;
        }

        # pass PHP scripts to FastCGI server
        #
        location ~ \.php$ {
               include snippets/fastcgi-php.conf;
        #
        #       # With php-fpm (or other unix sockets):
        ################## UBUNTU 22.04 LTS ##################
               fastcgi_pass unix:/var/run/php/php8.1-fpm.sock;
        ################## UBUNTU 20.04 LTS ##################
        #       fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;

        }

}
 
Back
Top