Extensible CMake toolchain for Nintendo Switch homebrew development with devkitA64 and libnx.
This project aims to provide a CMake toolchain for Nintendo Switch homebrew development using devkitA64 and libnx. It is intended as an alternative to the makefile-based system currently provided with the tools.
[TODO]
First, make sure you have installed the latest release of devkitA64, the Nintendo Switch homebrew development kit provided by devkitPro. Follow the installation guide here.
Important: Make sure that the devkitPro environment variables have been configured properly. CMake will use these to
locate the devkitA64 tools. Specifically, the ${DEVKITPRO}
variable should point to the devkitPro installation
directory.
You'll also need to have CMake.
To build the template examples, clone this repository and open a terminal in the root directory. Make a build directory with:
$ mkdir build
Next, have CMake configure the project and generate build files with:
$ cmake -G "Unix Makefiles" --toolchain=DevkitA64Libnx.cmake -S . -B build
The -G "Unix Makefiles"
argument specifies which
generator CMake will use. In this case, CMake will
output Makefiles when the project is built.
The --toolchain=DevkitA64Libnx.cmake
argument specifies which
toolchain file CMake will use. This will configure
CMake to use the DevkitPro environment and compilers.
Finally, build the project with
$ cmake --build build
You should now have a my_app.nro
executable in the ./build/templates/application/
directory.
Running your homebrew on your Nintendo Switch is easy when netloading with nxlink
, which is packaged with devkitA64.
Important: Your Switch needs to be running the Atmosphère custom
firmware with hbmenu
installed. Please also make sure the Switch is connected to the same wireless network as your
computer.
On your Nintendo Switch, open the Gallery applet to start hbmenu
, then press Y to start the netloader.
In the repository's root directory, run the following command to upload and run the executable:
$ nxlink ./build/templates/application/my_app.nro
If nxlink
fails with the message No response from Switch!
, try supplying the Switch's IP address via the -a <IP>
argument.
When the executable finishes uploading, you should see a Hello World!
message in the top left of your Switch's
display.