Andrettin / Wyrmsun

Strategy game based on history, mythology and fiction
http://andrettin.github.io/
GNU General Public License v2.0
307 stars 48 forks source link

Compiling Guide for Linux #177

Open dg1727 opened 4 years ago

dg1727 commented 4 years ago

This was requested in forum thread https://forum.freegamedev.net/viewtopic.php?f=94&t=12106

The following is my attempt. If it is OK, then I can sign up for the forum & add in this compiling guide. I raise the issue on GitHub because maybe this guide should go into readme.txt -- maybe people who are going to compile Wyrmsun are more likely to visit GitHub than to find the forum on FreeGameDev.net?


Written for Wyrmsun version 3.5.5

To compile Wyrmsun from GitHub on Linux, by downloading .ZIP files rather than cloning any Git repos:

Download the ZIP file from each of the following 3 GitHub pages:

https://github.com/Andrettin/Wyrmgus https://github.com/oamldev/oaml https://github.com/Andrettin/Wyrmsun

Unzip the 3 files. This will make folders called oaml-master/, Wyrmgus-master/, Wyrmsun-master/

All files that are in oaml-master/, copy them into Wyrmgus-master/src/oaml/

Open a terminal window in folder Wyrmgus-master/

Begin the following 2-step loop, until cmake finishes without error:

Step 1: cmake .

The full-stop character (.) is needed !

Step 2: Look at the error message to find out which package of header files to install from your Linux distro's package-management system. On Debian-based distros, header-file package names end in “-dev”. Some examples are:

If CMake can't find Lua, try installing liblua5.1-0-dev If CMake can't find SDL, try installing libsdl1.2-dev If CMake can't find ToLua++, try installing libtolua++5.1-dev

The one header package that wasn't in my distro was a recent enough version of Boost (Wyrmsun requires version 1.69 or higher). I installed libboost1.70 AND libboost1.70-dev from ppa:mhier/libboost-latest

If you aren't familiar with PPAs, you can verify what this PPA is by visiting https://launchpad.net/~mhier/+archive/ubuntu/libboost-latest

I needed to install libboost1.70 (without the -dev suffix) because of the nature of header files. Header files just tell the compiler how to call routines that are in an installed library. If the library itself isn't installed, then the header files allow your app to be compiled, but when you run your app, your app will try to call the library & will fail because the library isn't there. ...

... Libraries that are already installed by your distro (such as Lua and SDL) you don't need to install manually when you install the -dev header packages. Boost 1.70, on the other hand, wasn't installed by my distro, so I needed to install it (the library, in addition to the header files).

An exception to that rule seems to be ToLua++: It seems to have only a “-dev” package; there isn't a non-“-dev” package.

In order to install Boost 1.70, I needed to un-install libboost-dev AND libboost1.58-dev that had been provided by my distro.

End loop.

Type the following in your terminal window:

make

This will make an executable called stratagus

Copy that file to /usr/local/bin/ and rename the file to wyrmgus

(/usr/local/bin/ should already be one of the folders listed in your PATH environment-variable. This way, when Wyrmsun tries to run an executable called wyrmgus, Linux will find the file that you copied to /usr/local/bin/.)

sudo make install

This will copy the stratagus executable to /usr/local/games/, leaving the filename as stratagus, which is the wrong filename. The stratagus executable needs to be called wyrmgus because the executable wyrmsun, that will be made in the next few steps, is just a shell script that runs wyrmgus with a command-line parameter that points to the wyrmsun data files.

I left in the above sudo make install in case, now or in the future, that command does anything other than copy the stratagus executable with the wrong filename.

I happen to prefer installing games to /usr/local/bin/, but you can use /usr/local/games/ instead of /usr/local/bin/ if you want.

cd ../Wyrmsun-master

Repeat the same “cmake .” loop as for Wyrmgus

(Apparently, with Wyrmsun, unlike Wyrmgus, the make step isn't used, because no code is compiled for Wyrmsun. Wyrmsun consists of data files that are simply copied from your local Git repo or .ZIP file into /usr/local/ subfolders on your computer; this copying is done in the next step.)

sudo make install

You should now find Wyrmsun in the applications menu of your desktop environment.

Andrettin commented 4 years ago

Nice! Thank you for writing this :) Do you mind if I include it in the documentation?

ghost commented 4 years ago

Nice work!

Reading this and the quoted forum thread after few months, I am thinking that maybe things are too complex, maybe a coder (me?) sh/could make it easier? Fact is, I could eventually fix the CMakeLists.txt for linux users (maybe several other posix-like users, too) but not for windows. This would imply stop relying on the crappy cmake's FindPackage to use instead the "standard" pkgconfig tool, which is supported by cmake (via, ironically, the FindPackage instruction). This, at least since Debian stretch, so at least 2 years. I could try if simplifying the build for FOSS systems only is ok? (I don't intend to use cracked softwares or to pay (unrelated stuff) to help). Problem is, since pkgconfig only exists on linux, probably the *BSD, and maybe on MAC, Windows users would still need that failure loop.

A more usable solution for end user would be: creating a meta-project that uses the git submodule feature, and a cmake that does the git submodule sync and builds? I'll admit I don't know how to do that with cmake... shell would be easier for me. And still, it would not work on windows.

Exarkuniv commented 3 years ago

is this way still work for the current version. i see that the author says its for version 3.5.5.

also im trying to see if i can get it to work on a Pi4. so before i even started messing and getting angry. i thought i would ask

shirishag75 commented 2 years ago

One thing to note, unzipping oamldev from https://github.com/oamldev/oaml doesn't get oaml-master but oaml-1.3.4. Also there is no Wyrmgus-master but Wyrmgus-5.3.4. Had to make a directory called oaml inside of src/

~/games/Wyrmgus-5.3.4/src$ ls
action     database  guichan   map      particle    population  sound      time   upgrade  xbrz
ai         economy   include   missile  pathfinder  quest       species    tolua  util
animation  editor    item      network  pch.h       religion    spell      ui     video
beos       game      language  oaml     player      script      stratagus  unit   win32
Andrettin commented 2 years ago

One thing to note, unzipping oamldev from https://github.com/oamldev/oaml doesn't get oaml-master but oaml-1.3.4.

The engine used to require the OAML library, but no longer does. So in the current version that step isn't needed :)

shirishag75 commented 2 years ago

There seem to be some issues while compiling, can you help ???

~/games/Wyrmgus-5.3.4$ cmake .
-- sdl2 found: includes in /usr/include/SDL2, library in /usr/lib/x86_64-linux-gnu/libSDL2.so;-lpthread
CMake Warning (dev) at /usr/share/cmake-3.22/Modules/FindOpenGL.cmake:315 (message):
  Policy CMP0072 is not set: FindOpenGL prefers GLVND by default when
  available.  Run "cmake --help-policy CMP0072" for policy details.  Use the
  cmake_policy command to set the policy and suppress this warning.

  FindOpenGL found both a legacy GL library:

    OPENGL_gl_LIBRARY: /usr/lib/x86_64-linux-gnu/libGL.so

  and GLVND libraries for OpenGL and GLX:

    OPENGL_opengl_LIBRARY: /usr/lib/x86_64-linux-gnu/libOpenGL.so
    OPENGL_glx_LIBRARY: /usr/lib/x86_64-linux-gnu/libGLX.so

  OpenGL_GL_PREFERENCE has not been set to "GLVND" or "LEGACY", so for
  compatibility with CMake 3.10 and below the legacy GL library will be used.
Call Stack (most recent call first):
  CMakeLists.txt:1387 (find_package)
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Found OpenGL ES 1.1 libraries: /usr/lib/x86_64-linux-gnu/libSM.so;/usr/lib/x86_64-linux-gnu/libICE.so;/usr/lib/x86_64-linux-gnu/libX11.so;/usr/lib/x86_64-linux-gnu/libXext.so;/usr/lib/x86_64-linux-gnu/libEGL.so;/usr/lib/x86_64-linux-gnu/libGLESv1_CM.so
-- Checking for module 'sqlite3'
--   No package 'sqlite3' found
-- Could NOT find Sqlite (missing: SQLITE_INCLUDE_DIR SQLITE_LIBRARIES) 
-- Could NOT find Doxygen (missing: DOXYGEN_EXECUTABLE) 
-- Using OpenGL
==================================
Debug mode: No (Enable by param -DCMAKE_BUILD_TYPE=Debug)
Strip executables: No (Enable by param -DENABLE_STRIP=ON)
Static linking: No (Enable by param -DENABLE_STATIC=ON)
Place game files in: game directory (Place in user directory with -DENABLE_USEGAMEDIR=OFF)
Parallel building in MSVC: Yes (Disable by param -DENABLE_MULTIBUILD=OFF)
Platform: Linux
Redirect stdio: Unsupported on this platform
Touchscreen input: No (Enable by param -DENABLE_TOUCHSCREEN=ON)
Metaserver: No (Enable by param -DENABLE_METASERVER=ON)
Doxygen documentation: No (Enable by param -DENABLE_DOC=ON)
Game development files: No (Enable by param -DENABLE_DEV=ON)
Upx packer: No (Enable by param -DENABLE_UPX=ON)
X11: Found and enabled (Disable by param -DWITH_X11=OFF)
Renderer: OpenGL (Disable by param -DWITH_RENDERER=NativeSDL)
==================================
-- Configuring done
CMake Error at CMakeLists.txt:1765 (add_library):
  Target "wyrmgus" links to target "Qt5::LocationPrivate" but the target was
  not found.  Perhaps a find_package() call is missing for an IMPORTED
  target, or an ALIAS target is missing?

CMake Error at CMakeLists.txt:1765 (add_library):
  Target "wyrmgus" links to target "Qt5::LocationPrivate" but the target was
  not found.  Perhaps a find_package() call is missing for an IMPORTED
  target, or an ALIAS target is missing?

CMake Error at CMakeLists.txt:1766 (add_executable):
  Target "wyrmgus_main" links to target "Qt5::LocationPrivate" but the target
  was not found.  Perhaps a find_package() call is missing for an IMPORTED
  target, or an ALIAS target is missing?

CMake Error at CMakeLists.txt:1766 (add_executable):
  Target "wyrmgus_main" links to target "Qt5::LocationPrivate" but the target
  was not found.  Perhaps a find_package() call is missing for an IMPORTED
  target, or an ALIAS target is missing?

CMake Error at CMakeLists.txt:1769 (add_executable):
  Target "wyrmgus_test" links to target "Qt5::LocationPrivate" but the target
  was not found.  Perhaps a find_package() call is missing for an IMPORTED
  target, or an ALIAS target is missing?

CMake Error at CMakeLists.txt:1769 (add_executable):
  Target "wyrmgus_test" links to target "Qt5::LocationPrivate" but the target
  was not found.  Perhaps a find_package() call is missing for an IMPORTED
  target, or an ALIAS target is missing?

-- Generating done
CMake Generate step failed.  Build files cannot be regenerated correctly.

FWIW, did see https://stackoverflow.com/questions/65194181/unknown-modules-in-qt-location-private-positioning-private but there doesn't seem to be a debian positioning-private package at all. FWIW, I'm on Debian-testing with access to both debisn sid and experimental but can't find any sort of package in both the above package archives.

Andrettin commented 2 years ago

Setting the WITH_GEOJSON option to OFF should solve the issue. It's not really necessary for playing (it's used only for development), since the map data is pre-generated and checked in the data repository (Wyrmsun). I should probably set that option to OFF by default.

shirishag75 commented 2 years ago

Setting the WITH_GEOJSON option to OFF should solve the issue. It's not really necessary for playing (it's used only for development), since the map data is pre-generated and checked in the data repository (Wyrmsun). I should probably set that option to OFF by default.

That would be in cmakelists.txt ???

Andrettin commented 2 years ago

That would be in cmakelists.txt ???

Yes, but it's an option, so you can pass it to CMake, e.g.:

cmake . -DWITH_GEOJSON=OFF

In any case, I've made that option be false by default now with this commit: https://github.com/Andrettin/Wyrmgus

...so you can just use the latest master and it should work.

shirishag75 commented 2 years ago

That would be in cmakelists.txt ???

Yes, but it's an option, so you can pass it to CMake, e.g.:

cmake . -DWITH_GEOJSON=OFF

In any case, I've made that option be false by default now with this commit: https://github.com/Andrettin/Wyrmgus

...so you can just use the latest master and it should work.

damn, I downloaded the release, not the git repo :(

Also was looking for this -

https://stackoverflow.com/a/25317844/3597669 as there isn't a cmake clean command :(

shirishag75 commented 2 years ago

Also came across this -

~/games/Wyrmgus$ make
[  2%] Automatic MOC for target wyrmgus
[  2%] Built target wyrmgus_autogen
[  4%] Generating tolua.cpp

** tolua warning: Mapping variable to global may degrade performance.

Dunno if the tolua warning is significant or not.

Andrettin commented 2 years ago

Also came across this -

~/games/Wyrmgus$ make
[  2%] Automatic MOC for target wyrmgus
[  2%] Built target wyrmgus_autogen
[  4%] Generating tolua.cpp

** tolua warning: Mapping variable to global may degrade performance.

Dunno if the tolua warning is significant or not.

Good question. That warning has been in Stratagus for as long as I know the engine. It is unlikely to be an actual issue, I think. It's probably due to C++ global variables which are exposed to Lua via tolua++, but there are very few of them, and none of them are used in performance-critical code.

shirishag75 commented 2 years ago

In make after 72% -

[ 72%] Building CXX object CMakeFiles/wyrmgus.dir/Unity/unity_util_cxx.cxx.o
In file included from /home/shirish/games/Wyrmgus/src/util/assert_util.cpp:29,
                 from /home/shirish/games/Wyrmgus/CMakeFiles/wyrmgus.dir/Unity/unity_util_cxx.cxx:5:
/home/shirish/games/Wyrmgus/src/util/assert_util.h:43:50: error: ‘source_location’ in namespace ‘std’ does not name a type
   43 | inline std::string get_assert_message(const std::source_location &location)
      |                                                  ^~~~~~~~~~~~~~~
/home/shirish/games/Wyrmgus/src/util/assert_util.h:1:1: note: ‘std::source_location’ is defined in header ‘<source_location>’; did you forget to ‘#include <source_location>’?
  +++ |+#include <source_location>
    1 | //       _________ __                 __
/home/shirish/games/Wyrmgus/src/util/assert_util.h: In function ‘std::string wyrmgus::get_assert_message(const int&)’:
/home/shirish/games/Wyrmgus/src/util/assert_util.h:45:83: error: request for member ‘file_name’ in ‘location’, which is of non-class type ‘const int’
   45 |         return "Assert failed at " + get_source_relative_filepath_string(location.file_name()) + ": " + std::to_string(location.line()) + ", " + location.function_name() + ".";
      |                                                                                   ^~~~~~~~~
/home/shirish/games/Wyrmgus/src/util/assert_util.h:45:129: error: request for member ‘line’ in ‘location’, which is of non-class type ‘const int’
   45 | ed at " + get_source_relative_filepath_string(location.file_name()) + ": " + std::to_string(location.line()) + ", " + location.function_name() + ".";
      |                                                                                                      ^~~~

In file included from /home/shirish/games/Wyrmgus/src/util/assert_util.cpp:29,
                 from /home/shirish/games/Wyrmgus/CMakeFiles/wyrmgus.dir/Unity/unity_util_cxx.cxx:5:
/home/shirish/games/Wyrmgus/src/util/assert_util.h:45:155: error: request for member ‘function_name’ in ‘location’, which is of non-class type ‘const int’
   45 | ive_filepath_string(location.file_name()) + ": " + std::to_string(location.line()) + ", " + location.function_name() + ".";
      |                                                                                                      ^~~~~~~~~~~~~

/home/shirish/games/Wyrmgus/src/util/assert_util.h: At global scope:
/home/shirish/games/Wyrmgus/src/util/assert_util.h:50:55: error: ‘source_location’ in namespace ‘std’ does not name a type
   50 | inline void assert_throw(const bool check, const std::source_location &location = std::source_location::current())
      |                                                       ^~~~~~~~~~~~~~~
/home/shirish/games/Wyrmgus/src/util/assert_util.h:50:50: note: ‘std::source_location’ is defined in header ‘<source_location>’; did you forget to ‘#include <source_location>’?
   50 | inline void assert_throw(const bool check, const std::source_location &location = std::source_location::current())
      |                                                  ^~~
/home/shirish/games/Wyrmgus/src/util/assert_util.h:50:88: error: ‘std::source_location’ has not been declared
   50 | inline void assert_throw(const bool check, const std::source_location &location = std::source_location::current())
      |                                                                                        ^~~~~~~~~~~~~~~
/home/shirish/games/Wyrmgus/src/util/assert_util.h:67:53: error: ‘source_location’ in namespace ‘std’ does not name a type
   67 | extern void assert_log(const bool check, const std::source_location &location = std::source_location::current());
      |                                                     ^~~~~~~~~~~~~~~
/home/shirish/games/Wyrmgus/src/util/assert_util.h:67:48: note: ‘std::source_location’ is defined in header ‘<source_location>’; did you forget to ‘#include <source_location>’?
   67 | extern void assert_log(const bool check, const std::source_location &location = std::source_location::current());
      |                                                ^~~
/home/shirish/games/Wyrmgus/src/util/assert_util.h:67:86: error: ‘std::source_location’ has not been declared
   67 | extern void assert_log(const bool check, const std::source_location &location = std::source_location::current());
      |                                                                                      ^~~~~~~~~~~~~~~
In file included from /home/shirish/games/Wyrmgus/CMakeFiles/wyrmgus.dir/Unity/unity_util_cxx.cxx:5:
/home/shirish/games/Wyrmgus/src/util/assert_util.cpp:36:46: error: ‘source_location’ in namespace ‘std’ does not name a type
   36 | void assert_log(const bool check, const std::source_location &location)
      |                                              ^~~~~~~~~~~~~~~
/home/shirish/games/Wyrmgus/src/util/assert_util.cpp:32:1: note: ‘std::source_location’ is defined in header ‘<source_location>’; did you forget to ‘#include <source_location>’?
   31 | #include "util/log_util.h"
  +++ |+#include <source_location>
   32 | 
make[2]: *** [CMakeFiles/wyrmgus.dir/build.make:627: CMakeFiles/wyrmgus.dir/Unity/unity_util_cxx.cxx.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:90: CMakeFiles/wyrmgus.dir/all] Error 2
make: *** [Makefile:166: all] Error 2
Andrettin commented 2 years ago

Which compiler are you using? And which version?

shirishag75 commented 2 years ago
$ make -version
GNU Make 4.3
Built for x86_64-pc-linux-gnu
Copyright (C) 1988-2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

And cmake is -

$ cmake --version
cmake version 3.22.1

CMake suite maintained and supported by Kitware (kitware.com/cmake).

Sharing both as I first used cmake and then make on the above.

GCC is -

$ gcc --version
gcc (Debian 11.2.0-16) 11.2.0
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Andrettin commented 2 years ago

@shirishag75 Thanks!

I've made some commits which might fix this issue: https://github.com/Andrettin/Wyrmgus/commit/ec57e124c12689082489ecec1b53796567151663 https://github.com/Andrettin/Wyrmgus/commit/c10a621c4ec279092c7d7afe9dd7d236ca70408e

Let me know if it works!

shirishag75 commented 2 years ago

That worked.

[ 88%] Automatic MOC for target wyrmgus_test
[ 88%] Built target wyrmgus_test_autogen
[ 90%] Building CXX object CMakeFiles/wyrmgus_test.dir/wyrmgus_test_autogen/mocs_compilation.cpp.o
[ 92%] Building CXX object CMakeFiles/wyrmgus_test.dir/Unity/unity_economy_test_cxx.cxx.o
[ 94%] Building CXX object CMakeFiles/wyrmgus_test.dir/Unity/unity_game_test_cxx.cxx.o
[ 96%] Building CXX object CMakeFiles/wyrmgus_test.dir/Unity/unity_util_test_cxx.cxx.o
[ 98%] Building CXX object CMakeFiles/wyrmgus_test.dir/test/main.cpp.o
[100%] Linking CXX executable wyrmgus_test

Now I'm unsure what the next steps are, This is how it looks -

$ ls 
cmake                       CMakeLists.txt           gameheaders        src              wyrmgus.dir
CMakeCache.txt              COPYING                  HOWTO-NEW-RELEASE  test             wyrmgus_main_autogen
CMakeDoxyfile.in            CPackConfig.cmake        libwyrmgus.a       tolua.cpp        wyrmgus_test
CMakeDoxygenDefaults.cmake  CPackSourceConfig.cmake  Makefile           tools            wyrmgus_test_autogen
CMakeFiles                  CTestTestfile.cmake      metaserver         wyrmgus
cmake_install.cmake         doc                      po                 wyrmgus_autogen

I want to play the game without installing it either in /usr/local/bin/ or /usr/local/games/. Any help would be useful.

shirishag75 commented 2 years ago

Could you share a snapshot or a release of the latest master so I could give a try again, thank you.

Andrettin commented 2 years ago

Could you share a snapshot or a release of the latest master so I could give a try again, thank you.

I'm not entirely sure what you mean. Do you mean providing binaries of the latest master?

shirishag75 commented 2 years ago

Could you share a snapshot or a release of the latest master so I could give a try again, thank you.

I'm not entirely sure what you mean. Do you mean providing binaries of the latest master?

npt binaries per-se but zip files, so I can just do as shared by OP. The only difference is no oaml needed :)

Andrettin commented 2 years ago

npt binaries per-se but zip files, so I can just do as shared by OP. The only difference is no oaml needed :)

Oh... well, why not just go to the repository, click on the "Code" button, and then "Download ZIP"?

shirishag75 commented 2 years ago

npt binaries per-se but zip files, so I can just do as shared by OP. The only difference is no oaml needed :)

Oh... well, why not just go to the repository, click on the "Code" button, and then "Download ZIP"?

OMG, my bad sorry. Any answers to this though

https://unix.stackexchange.com/questions/709593/how-do-i-enable-cmake-give-me-the-compilation-output-one-screenful-at-a-time-ins

Andrettin commented 2 years ago

I would just try to scroll up after doing "cmake ." to read the rest of the output. Is that not viable for some reason?

shirishag75 commented 2 years ago

I would just try to scroll up after doing "cmake ." to read the rest of the output. Is that not viable for some reason?

I use guake and in guake, yukake you just can't do it like that. Also I have a small monitor :(

ghost commented 2 years ago

You could pipe the output to less? As in: make 2>&1 | less -R. If you manage to find how to force make to have colored output despite the pipe, well, you'll be just fine. Otherwise you'll have to manage with monochrome text. Less is installed on all distros I know, and is even part of busybox, so there's very little chances you do not have a version of it around.

Mailaender commented 1 year ago

I have some trouble updating https://github.com/flathub/io.github.Andrettin.Wyrmsun because you require Boost 1.69, but also get fatal error: boost/asio/awaitable.hpp: No such file or directory which is not part of the Boost distribution anymore. When I install https://sourceforge.net/projects/asio/ it still can't find it.