I had difficulty finding much information regarding these topics, I want everyone to be able to see at a glance that this does indeed work, thanks again my friend!
Install the version corresponding to your Operating System (64 or 32 bits).
Accept the defaults in installation program of MSYS2 once you finish the installation you will have shortcuts for MSYS2, MinGW32 and MinGW64. MSYS2 is used to compiling POSIX binaries for Linux from Windows.
MinGW32 & MinGW64 compile Native Windows binaries using a linux toolchain (gcc, bash, etc.)
Launch MSYS2 shell and execute the command: pacman -Syuu several times until you get the message: "there is nothing to do".
In order to compile the Switch binary you must first confirm all works fine compiling a binary for Windows. So do the next steps:
Install prerequisites
In a MinGW64 shell (or MinGW32 if you have a Windows 32 bit edition, why?). Be sure the prompt shows MINGW64 or MINGW32 if not you started the wrong shell, close it and open the right one.
Please execute the next command, several times until you get the message "there is nothing to do", you can be asked to restarts the MINGW64 environment few times: pacman -Syuu
Pay attention to the space before " -lstdc++". then run the commands:
Code:
cd ..
make
Last, you can compile the Widows executable using make and the build options you choose, by example:
Code:
cd ..
make BETTERCAMERA=1 NODRAWINGDISTANCE=1 TEXTURE_FIX=1 EXT_OPTIONS_MENU=1 -j9
If all go through you get an .exe file on build subfolder of sm64ex.
Troubleshooting
If you get the error gcc: command not found or make: gcc: No such file or directory you do not install all needed packages or run the wrong Shell, be sure of running «MINGW32» or «MINGW64» and what that is pointed on the prompt in purple.
If the ROM is missing or wrong format/version you get the error Failed to open baserom.us.z64! Verify the correct ROM at the c:\msys64\home\<username>\sm64ex.folder.
If you get the error make: *** No targets specified and no makefile found. Stop. You are on the wrong folder the last make command should be run from c:\msys64\home\<username>\sm64ex folder.
Be sure of get the responses Target: i686-w64-mingw32 or Target: x86_64-w64-mingw32 when you run the command gcc -v if else other is shown on screen you install the wrong gcc package or run MSYS shell, remember the process should be run on «MINGW32» or «MINGW64» shells.
Nintendo Switch compilation.
After all works fine and a Windows binary is created, you can run extra steps for make a Switch NRO file
First you need to install DevKitPro.
You need to edit the pacman.conf on c:\msys64\etc\
And add the next lines at end of it:
Code:
[dkp-libs]
Server = https://downloads.devkitpro.org/packages
[dkp-windows]
Server = https://downloads.devkitpro.org/packages/windows
By last run the next commands in order to make the NRO file, PLEASE DO NOT FORGET TO COPY THE EXE FILE GENERATED FOR WINDOWS TO OTHER PATH, it will be deleted on the next step.
You can use any build options you want, one example:
Code:
make TARGET_SWITCH=1 BETTERCAMERA=1 NODRAWINGDISTANCE=1 TEXTURE_FIX=1 -j9
BUILD OPTIONS
Build option
Default
Possible values
Description
VERSION
us
us, eu, jp, sh
Which ROM to use. The selected ROM has to be in the repo folder with the name baserom.$VERSION.z64. sh is currently broken.
TARGET_BITS
32, 64,
TARGET_BITS=n appends some compiler flags for an n-bit build. If the value is empty, the option does nothing, assuming your native toolchain will set everything up by itself. Use this only if you're having trouble otherwise.
If 1, build for Windows. Usually set automatically if building on Windows.
OSX_BUILD
0
0, 1
If 1, build for OSX.
WINDOWS_CONSOLE
0
0, 1
If 1, append -mconsole to Windows CFLAGS, making a console window appear while the game is running. Can be useful for debugging purposes.
DEBUG
0
0, 1
If 1, build with debug symbols and default optimization level. Otherwise build with -O2.
RENDER_API
GL
GL, GL_LEGACY, D3D11, D3D12
Select rendering backend to use.
GL corresponds to OpenGL 2.1 (gfx_opengl.c),
GL_LEGACY corresponds to OpenGL 1.3 (gfx_opengl_legacy.c).
Direct3D backends will also force WINDOW_API to DXGI.
WINDOW_API
SDL2
SDL2, DXGI
Select windowing backend. GL renderers force SDL2 and D3D renderers force DXGI for now, so you don't need to specify this.
AUDIO_API
SDL2
SDL2
Select audio backend. There's only one right now.
CONTROLLER_API
SDL2
SDL2
Specify list of controller backends to use. There's only one right now.
BETTERCAMERA
0
0, 1
If 1, build with analog camera support (uses Puppycam).
NODRAWINGDISTANCE
0
0, 1
If 1, build with disabled draw distance (every object is active at all times). May affect gameplay.
TEXTURE_FIX
0
0, 1
If 1, enable various texture-related bugfixes (e.g. fixes the smoke texture).
EXT_OPTIONS_MENU
1
0, 1
If 1, enable Options menu. Accessed from the Pause menu by pressing R.
EXTERNAL_DATA
0
0, 1
If 1, load textures and soundbanks from external files. Allows you to use texture packs. The default data is copied to a res folder next to the produced executable. (En Switch va en la carpeta raíz), para PC no lo genera
DISCORDRPC
0
0, 1
If 1, enable Discord Rich Presence support. Only works on x86_64.
TEXTSAVES
0
0, 1
If 1, use INI-based save format instead of binary EEPROM dumps. Experimental.
Optional Steps
If you want a Banner for the NRO file, you need to put a file called nx_icon.jpg on the sm64ex folder and BEFORE run the last make command you edit the Makefile file and replace the next lines
Code:
# add `--icon=$(APP_ICON)` to this when we get a suitable icon
%.nro: %.stripped %.nacp
@elf2nro $< [email protected] --nacp=$*.nacp
@echo built ... $(notdir [email protected])
By these:
Code:
# add `--icon=$(APP_ICON)` to this when we get a suitable icon
%.nro: %.stripped %.nacp
@elf2nro $< [email protected] --nacp=$*.nacp --icon=$(APP_ICON)
@echo built ... $(notdir [email protected])
After the NRO file is created, you can use SAK Switch Army Knife to make a NSP forwarder installable on the HOS.
Once again I fell down the martial arts rabbit hole and am plumbing the murky depths of the internet's various martial arts and fighting crafts echo chambers.
If you're not actively involved and only get up to speed every few years or so, you can see the tide of public opinion flapping worse than my dong while I'm skipping naked down a hallway.