NorthstarLauncher icon indicating copy to clipboard operation
NorthstarLauncher copied to clipboard

Figure out building Northstar on Linux

Open GeckoEidechse opened this issue 2 years ago • 2 comments

We use msbuild, which is Windows only?

We should figure out how to compile on Linux to make developing on Linux easier.

Note that this means still creating a Windows executable. As Titanfall2 is a Windows only game there's no point in creating a Linux-native version of Northstar as that version would have to interface with Wine/Proton instead and hook functions there which require a complete rewrite just for Linux. Given that Northstar works fine running under Wine/Proton, there's no point in putting in the huge amount of effort required for working Linux native builds.

GeckoEidechse avatar Jun 26 '22 20:06 GeckoEidechse

  • https://github.com/paleozogt/MSVCDocker
  • https://github.com/madduci/docker-msvc-cpp
  • https://github.com/mstorsjo/msvc-wine

Highly suggesting the last one (it defaults to VS2022 contrary to what readme says). Is the most painless since it downloads files automatically without requiring Vagrant Windows image to presetup.

The only other option is to use a different Linux-native compiler, which I don't really recommend due to possible ABI incompatibilities that will not necessarily be nice to debug for people trying this approach, though @pg9182 disagreed with my opinion on this before...

p0358 avatar Jun 28 '22 00:06 p0358

I am planning to open a series of PRs based on my own configs:

  • #226
  • Additional non-critical fixes for compiler warnings and header include cleanups.
  • Reorganize third-party dependencies.
  • Meson build script (cross-platform).
  • CI builds on Linux.

The end goal will be to have everything in Northstar compiled with llvm-mingw-msvcrt (instead of msvc) using meson build scripts (instead of msbuild), with all CI being done on Linux.

Benefits:

  • Simplify developing Northstar on Linux.
  • Give us better compiler warnings from clang.
  • Allow us to use modern compiler features.
  • Allow us to use standard C++ features rather than MSVC extensions.
  • Unify launcher builds.
  • Allow the docker container to build ns components from source.
  • Preserve ABI compatibility.
  • Simplify the source layout.
  • Simplify including third-party libraries.

Costs:

  • Slightly larger launcher binaries.
  • A few extra one-time steps for setting up a development environment on Windows (install LLVM toolchain, install Meson, generate vcxproj).

pg9182 avatar Jul 23 '22 23:07 pg9182

If your goal is cross-platform development, I'd recommend adding support for building through CMake over Meson, since it's the defacto standard build system for C++at this point and is very good for cross-platform. It also has native integrations with multiple IDEs, including Visual Studio, meaning it should be just as easy for anyone using VS to use the CMake file as it is to use the solution file.

I've made a commit that's able to successfully build through CMake through MSVC and I'm using it to look at what's required for building with mingw. Let me know if you'd like a PR.

apophis42 avatar Nov 27 '22 23:11 apophis42

I've made a commit that's able to successfully build through CMake through MSVC and I'm using it to look at what's required for building with mingw. Let me know if you'd like a PR.

PR would always be appreciated <3

GeckoEidechse avatar Nov 28 '22 00:11 GeckoEidechse

My friend and I managed to make the changes required for a successful mingw build, so I can PR that once the previous is accepted.

apophis42 avatar Nov 29 '22 17:11 apophis42

elek on Discord got NorthstarLauncher to compile under msvc-wine.

This has been tested on at least Arch and Fedora but is likely to work on more distros.

Instructions copied straight from Discord (message):

Arch Linux instructions

  • Dependecies(used versions in brackets):
  • wine (8.11) [Multilib needs to be uncommented /etc/pacman.conf]
  • wine-mono
  • python (3.11.3)
  • msitools
  • python-simplejson (3.19.1)
  • python-six (1.16.0)
  • cmake
  • ninja
  • make
  • samba (4.18.3) [contains winbind]
  • libunwind

Create a folder for msvc installation but don't enter it (e.g. ~/msvc) Clone msvc-wine and enter folder. (git clone https://github.com/mstorsjo/msvc-wine) ./vsdownload.py --dest <folder for msvc installation> (e.g. ~/msvc) Accept Licence Agreement ./install.sh <folder of the msvc installation>

export PATH=<path to msvc installation>/bin/x64:$PATH

Clone NorthstarLauncher and switch into clone repo CC=cl CXX=cl cmake . -DCMAKE_BUILD_TYPE=Release -DCMAKE_SYSTEM_NAME=Windows -G "Ninja"

cmake --build .

Jan200101 avatar Jul 05 '23 07:07 Jan200101

Furthermore, you can also add -DCMAKE_EXPORT_COMPILE_COMMANDS=1 to make it work well with the vscode-clangd extension (along with clang-cl).

pg9182 avatar Jul 06 '23 03:07 pg9182

This is basically solved with #501

We only need to add the instructions to documentation ^^

GeckoEidechse avatar Jul 20 '23 14:07 GeckoEidechse