Talk:Source code compiling/Makefiles

From SRB2 Wiki
Jump to navigation Jump to search

mingw-w64 Installations

Here's what I've been telling people how to compile 64-bit SRB2.

Download the Package

Refer to this list of mingw-w64 packages from SourceForge, at the bottom of the files page.

https://sourceforge.net/projects/mingw-w64/files/#readme

I use these packages -- GCC 7.3.0. Download both of these packages to build for both 32-bit and 64-bit. You need both packages separately to compile for either bitness.

Note

What the package name means

"win32" refers to the package's threading model -- either "win32" or "posix". Some programs use "posix" threading exclusively. I don't know if srb2win works better with a posix-threaded mingw package.

"dwarf"/"seh" refers to the package's exception model -- either sjlj, dwarf, or seh.

  • sjlj incurs a measurable performance penalty, but works across code that's not specifically compiled for sjlj exceptions.
  • dwarf is 32-bit only and zero-penalty, but each library needs to be compiled to dwarf for that library to report exceptions. SRB2 contains references to dwarf in its makefiles, so I interpret that as the preferred exception model.
    • (For the record, I compiled the 32-bit releases with SJLJ, but maybe I shouldn't be doing that...)
  • seh is 64-bit only and compatible with Windows' native exception handling. I'm not sure if this is preferred over SJLJ for 64-bit, but this is what I use to compile the 64-bit releases.
Note
Regarding the OSDN note: "mingw" has made its home on OSDN, but "mingw-w64" very much lives currently on SourceForge. The last updates are from December 2018. "mingw-w64" is a more modern fork of what was once called "mingw". "mingw-w64" compiles for both 64-bit and 32-bit.

How to Setup

I like using the 7-zip packages from SourceForge because I don't need to deal with any weird installers.

The compiler and debugger are exactly where I extract them, and I know exactly what is happening to them and what steps I did to set them up.

  1. Download both 32-bit and 64-bit mingw-w64 packages, if you want to compile for both 32-bit and 64-bit.
  2. Extract the 7-zip packages to separate folders
  3. Remove any current MinGW installations from your PATH.
  4. Optionally, add the new MinGW-W64 installation to the beginning of your PATH -- only one at any time.
    • So if you want to compile for 64-bit, add the 64-bit MinGW-W64 installation to your PATH. To compile for 32-bit, add the 32-bit MinGW-W64 installation. Do not have both in the PATH at the same time.
    • You may be able to get away with not using the PATH at all, and just calling mingw32-make.exe with its direct location. I have not tested this.

How to Compile

If you added the 32-bit or 64-bit install to your PATH:

  • 32-bit: mingw32-make.exe MINGW=1 SDL=1 CC=gcc WINDOWSHELL=1 NOOBJDUMP=1
  • 64-bit: mingw32-make.exe MINGW64=1 SDL=1 CC=gcc WINDOWSHELL=1 NOOBJDUMP=1

If you have not added either install to your PATH, call the make EXE directly (I have not tested this):

  • 32-bit: C:\path\to\i686-mingw-w64\bin\mingw32-make.exe MINGW=1 SDL=1 CC=gcc WINDOWSHELL=1 NOOBJDUMP=1
  • 64-bit: C:\path\to\x86_64-mingw-w64\bin\mingw32-make.exe MINGW64=1 SDL=1 CC=gcc WINDOWSHELL=1 NOOBJDUMP=1

How to Run

When you double-click the srb2win.exe and it gives you a 0xc0000007b error, that means you do not have the correct DLLs to run the EXE. You need to include these in the same folder as the EXE:

How to Debug

gdb.exe is located in C:\path\to\mingw-w64\bin\gdb.exe. Both 32-bit and 64-bit debugging work for me in Visual Studio Code -- variables, breakpoints, etc. I haven't tried it outside of that program.

Alternatively, AppVeyor

Finally, as an alternative to setting up mingw, you can also recommend people to use AppVeyor to build their binaries, both 32 and 64-bit. This is undoubtedly easier than setting up your own toolchain -- but slightly less convenient than building on your own machine.

Provide instructions to push their code to GitHub, then set up their SRB2 fork at appveyor.com, then it will build the EXEs automatically and upload them as job artifacts. Ask Jimita -- I got the idea from him :)

Digiku talk 04:11, 7 January 2019 (UTC)