Skip to content

Setting up MinGW for WSL‐less build

Denis Kopyrin edited this page Nov 14, 2024 · 3 revisions

How to build HackerSM64 using MinGW on Windows. Compilers SDK will take ~1Gb of disk space + cmder takes ~400MB and python takes ~150MB totally in roughly ~1.5GB of disk space.

  1. Download necessary tools
  1. Install python using downloaded exe.

Select "Use admin priviliges when installer py.exe" and "Add python.exe to PATH". Click "Customize installation". Unselect all checkboxes. Only select checkboxes "Documentation", "pip" and "for all users (requires admin priviliges)". Click "Next". Unselect all checkboxes. Only select "Install Python 3.12 for all users", "Add Python to environment variables" and "Precompile standard library". Click "Install", wait for it to finish. If available, click "Disable path length limit". Click "Close". Go to folder when python was installed (likely "C:/Program Files/Python312". Copy "python.exe" to "python3.exe".

  1. Extract winlibs and winn64libs folders.

I will use dir "C:/" for convenience. I suggest using short folders without any whitespaces. I assume that folders were unpacked in "C:/winlibs" and "C:/n64libs". Ensure that folders have "bin" in the root like "C:/winlibs/bin" and "C:/n64libs/bin".

  1. Add all extracted binaries to system "PATH".

In search bar search for "Edit the system environment variables". Click on "Environment Variables...". in "System Variables" double click on "Path" entry. Click "New", then "Browse" and select "C:/winlibs/bin". Perform the same for "C:/n64libs/bin".

Now remove WindowsApps from PATH because it will cause issues with Python we installed. In "User variables from admin" click on "Path", select "%USERPROFILE%/AppData/Local/Microsoft/WindowsApps", click "Delete".

Click "OK" to apply the changes, close "System Properties" window.

  1. Extract cmder.zip folder. For convenience, i will use folder "C:/cmder".
  2. Extract rg.exe from ripgrep zip in folder ripgrep-14.1.0.x86_64-pc-windows-msvc. Put rg.exe in bin folder near Cmder.exe, in my case it is folder C:\Cmder\bin.
  3. Launch "Cmder.exe". If prompted with warning "ConEmu binaries are marked as 'Downloaded from Internet'", click "Unblock and Continue". Ensure that compilers work: execute gcc -v, mips-n64-gcc -v and rg -V. You should observe the output similar to the following:
λ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=D:/winlibs/bin/../libexec/gcc/x86_64-w64-mingw32/14.1.0/lto-wrapper.exe
OFFLOAD_TARGET_NAMES=nvptx-none
Target: x86_64-w64-mingw32
Configured with: ../configure --prefix=/R/winlibs64ucrt_stage/inst_gcc-14.1.0/share/gcc --build=x86_64-w64-mingw32 --host=x86_64-w64-mingw32 --enable-offload-targets=nvptx-none --with-pkgversion='MinGW-W64 x86_64-ucrt-posix-seh, built by Brecht Sanders, r1' --with-tune=generic --enable-checking=release --enable-threads=posix --disable-sjlj-exceptions --disable-libunwind-exceptions --disable-serial-configure --disable-bootstrap --enable-host-shared --enable-plugin --disable-default-ssp --disable-rpath --disable-libstdcxx-debug --disable-version-specific-runtime-libs --with-stabs --disable-symvers --enable-languages=c,c++,fortran,lto,objc,obj-c++ --disable-gold --disable-nls --disable-stage1-checking --disable-win32-registry --disable-multilib --enable-ld --enable-libquadmath --enable-libada --enable-libssp --enable-libstdcxx --enable-lto --enable-fully-dynamic-string --enable-libgomp --enable-graphite --enable-mingw-wildcard --enable-libstdcxx-time --enable-libstdcxx-pch --with-mpc=/d/Prog/winlibs64ucrt_stage/custombuilt --with-mpfr=/d/Prog/winlibs64ucrt_stage/custombuilt --with-gmp=/d/Prog/winlibs64ucrt_stage/custombuilt --with-isl=/d/Prog/winlibs64ucrt_stage/custombuilt --disable-libstdcxx-backtrace --enable-install-libiberty --enable-__cxa_atexit --without-included-gettext --with-diagnostics-color=auto --enable-clocale=generic --with-libiconv --with-system-zlib --with-build-sysroot=/R/winlibs64ucrt_stage/gcc-14.1.0/build_mingw/mingw-w64 CFLAGS='-I/d/Prog/winlibs64ucrt_stage/custombuilt/include/libdl-win32   -march=nocona -msahf -mtune=generic -O2 -Wno-error=format' CXXFLAGS='-Wno-int-conversion  -march=nocona -msahf -mtune=generic -O2' LDFLAGS='-pthread -Wl,--no-insert-timestamp -Wl,--dynamicbase -Wl,--high-entropy-va -Wl,--nxcompat -Wl,--tsaware' LD=/d/Prog/winlibs64ucrt_stage/custombuilt/share/binutils/bin/ld.exe

Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 14.1.0 (MinGW-W64 x86_64-ucrt-posix-seh, built by Brecht Sanders, r1)

λ mips-n64-gcc -v
Using built-in specs.
COLLECT_GCC=mips-n64-gcc
COLLECT_LTO_WRAPPER=d:/crash/sdk/bin/../libexec/gcc/mips-elf/12.2.0/lto-wrapper.exe
Target: mips-elf
Configured with: ../gcc-12.2.0/configure --prefix=/d/crash/sdk --with-gnu-as=/d/crash/sdk/bin/mips-n64-as --with-gnu-ld=/d/crash/sdk/bin/mips-n64-ld --target=mips-elf --program-prefix=mips-n64- --with-arch=vr4300 --with-tune=vr4300 --enable-languages=c,c++ --with-newlib --disable-libssp --disable-multilib --disable-shared --with-gcc --disable-threads --disable-win32-registry --disable-nls --disable-werror --with-abi=32 --with-float=hard --with-fp-32=32 --with-fpu=double --with-system-zlib --with-specs='-mno-abicalls -fno-PIC -mgp32  -march=vr4300 -mtune=vr4300 -mfix4300'
Thread model: single
Supported LTO compression algorithms: zlib zstd
gcc version 12.2.0 (GCC)

λ rg -V
ripgrep 14.1.0 (rev e50df40a19)

Ensure that "MinGW-W64 x86_64-ucrt-posix-seh" is present in gcc output.

  1. Clone repo using tutorial. Fork repository and create a clone of https://github.com/HackerN64/HackerSM64. I assume it is cloned to 'C:\HackerSM64-MinGW'.
  2. Place legally obtained "baserom.us.z64" in C:\HackerSM64-MinGW.
  3. To build the repository, change directory to "C:\HackerSM64-MinGW" in cmder and use command "mingw32-make -j12". Please change "12" to amount of CPU cores.
λ mingw32-make
Building tools...
Building ROM...

Note that you may get an error first run, rerun mingw32-make again if it happens.