Building Atmosphère on Windows using MSYS2

Sometimes you need to build the binaries for Atmosphère, or you want to change something on the source code, for building your starting point should be: https://github.com/Atmosphere-NX/Atmosphere/blob/master/docs/building.md
On that document you can read:
Building Atmosphère is a very straightforward process that relies almost exclusively on tools provided by the devkitPro organization.​
Dependencies:
  • devkitA64
  • devkitARM
  • Python 2 (Python 3 may work as well, but this is not guaranteed)
  • LZ4
  • PyCryptodome (optional)
  • Hactool
Setup a DevKitPro environment: (https://devkitpro.org/wiki/Getting_Started)
Install the following packages via (dkp-)pacman:​
  • switch-dev
  • switch-glm
  • switch-libjpeg-turbo
  • devkitARM
  • devkitarm-rules
  • hactool
Install the following library via python's package manager pip, required by exosphere:​
  • lz4
Finally, clone the Atmosphère repository and run make under its root directory.​

That instructions are a little plain for we the noobs.

First you need Install a MSYS environment:
The latest instructions for install the MSYS environment are on https://gbatemp.net/threads/install-msys-environment.652234/ if you don't have one working, use them.

After you have the MSYS environment working you need to install DevKitPro
For that you can follow the instructions on the tutorial https://gbatemp.net/threads/setup-a-devkitpro-environment-on-windows.652238/

Now you can install DevKitPro packages:
Bash:
pacman -S --noconfirm switch-dev devkitA64 dkp-toolchain-vars libnx switch-tools switch-mesa switch-libdrm_nouveau switch-sdl2

And Atmosphère prerequisites
Bash:
Pacman -Sy --noconfirm devkitA64 devkitARM devkitarm-rules hactool mingw-w64-x86_64-python mingw-w64-x86_64-python-lz4 mingw-w64-x86_64-python-pycryptodome switch-dev switch-glm switch-libjpeg-turbo mingw-w64-x86_64-python-pip

For me I had to add zip package because even if wasn't explicit indicated on the build page, the code needs it.

Additional you need the packages git make lz4 for all to work, use the command:

Bash:
Pacman -Sy --noconfirm zip git make lz4


The package hactool need you to copy your own prod.keys file on $HOME/.switch folder. (c:\msys64\home\USERNAME\.switch if you use the default installation folder)

LibNX Dependency
Atmosphère depends heavily on LibNX, generally when a major version of firmware is released or great changes on the code are made, changes to LibNX are also made.
The Atmosphère team works on their own repo of LibNX (https://github.com/Atmosphere-NX/libnx) and forward Pull Request to official SwitchBrew LibNX repo (https://github.com/switchbrew/libnx).

So if there are changes on LibNX you need to build it and install on your setup.
If you haven't done already, setup the environment variables

Bash:
export DEVKITPRO=/opt/devkitpro
export DEVKITARM=${DEVKITPRO}/devkitARM
export DEVKITPPC=${DEVKITPRO}/devkitPPC
export PATH=${DEVKITPRO}/tools/bin:$PATH
Then go to the Atmosphere-NX/LibNX repo and look what is the new branch for the current firmware, by example, for Firmware 16.0.0 the branch name is "1600_Support"

1677718224337.png

Then go to your MSYS MinGW64 window and clone the Atmosphere-NX/LibNX repo

Bash:
cd ~
git clone --recursive https://github.com/Atmosphere-NX/libnx.git
cd libnx

And checkout the needed branch:

Bash:
git checkout 1600_support

Then build and install the new LibNX libraries

Bash:
make install -j$(nproc)

Now you can build Atmosphère with latest LibNX code; remember if you update the pacman LibNX package the changes get reversed and you need to build LibNX again.

Now is time to build the binaries
Clone the repository:
Bash:
cd ~
git clone --recursive https://github.com/Atmosphere-NX/Atmosphere

Go to new created Atmosphère folder
Bash:
cd Atmosphere

Never forget to create the environment variables for DevKitPro
Bash:
export DEVKITPRO=/opt/devkitpro
export DEVKITARM=/opt/devkitpro/devkitARM
export DEVKITPPC=/opt/devkitpro/devkitPPC

And now you are ready to start the building process:
Bash:
make -j$(nproc)

I do use the "-j$(nproc)" parameter to "bleed" all the available CPU to run the compiler, without that the whole process could take up to 1 hour.

I want to thank a lot to @binkinator and @godreborn for all the help and inspiration to make this guide, and want to ask you for help improving this guide.

Also special thanks to @godreborn for been a support of the users replies and suggestions to the OP.

Remember, as you are getting a new set of binaries, you need new set of sigpatches if you use it. So the great tool from @mrdude comes in hand, the latest release can be downloaded from: https://github.com/mrdude2478/IPS_Patch_Creator/releases/; you use the program to generate a new set of patches for your recently build package3 file.


Latest IPS Patch Creator:
Sigpatch-IPS-Creator_1.5.7_Yandex.png





-Edited: add sigpatches step and clean up a little-
-Edit 2, add LibNX build-
 

Attachments

  • 1695782853186.png
    1695782853186.png
    62.7 KB · Views: 50
  • 1695782902542.png
    1695782902542.png
    6.4 KB · Views: 51
Last edited by impeeza,

impeeza

¡Kabito!
OP
Member
Joined
Apr 5, 2011
Messages
6,360
Trophies
3
Age
46
Location
At my chair.
XP
18,714
Country
Colombia
Yeah, on the DevKitInstaller the instructions recommend to using MinGW64
Post automatically merged:

I do correct my self: used to recommend MinGW64, now the DevKitPro Installer for Windows Create a Link for MSYS.

But really do not should matter because DevKitPro uses their own libraries.
Post automatically merged:

Well just for couriosity, I just build Atmosphère on MSYS environment and went well, but you need to install this packages:

Bash:
Pacman -Syuu --noconfirm --needed zip git make lz4 libnx devkitA64 devkitARM devkitarm-rules hactool switch-dev dkp-toolchain-vars switch-tools switch-mesa switch-libdrm_nouveau switch-sdl2 switch-libjpeg-turbo switch-glm gcc python python-pip
pip install lz4 pycryptodome


Because on MSYS python is more like the one on linux, on MinGW64 is more like Windows one. and you need to explicit install gcc.
 
Last edited by impeeza,

Muxi

Well-Known Member
Member
Joined
Jun 1, 2016
Messages
605
Trophies
0
Age
52
XP
2,120
Country
Germany
Is there something wrong with my approach that it may not work for me?

Code:
1.
export DEVKITPRO=/opt/devkitpro
export DEVKITARM=${DEVKITPRO}/devkitARM
export DEVKITPPC=${DEVKITPRO}/devkitPPC
export PATH=${DEVKITPRO}/tools/bin:$PATH

2.
cd ~
git clone --recursive https://github.com/switchbrew/libnx.git
cd libnx

3.
make all

4.
make install

5.
cd ~
git clone --recursive https://github.com/Atmosphere-NX/Atmosphere

6.
cd Atmosphere

7.
export DEVKITPRO=/opt/devkitpro
export DEVKITARM=/opt/devkitpro/devkitARM
export DEVKITPPC=/opt/devkitpro/devkitPPC

8
make -j$(nproc)
 

impeeza

¡Kabito!
OP
Member
Joined
Apr 5, 2011
Messages
6,360
Trophies
3
Age
46
Location
At my chair.
XP
18,714
Country
Colombia
Is there something wrong with my approach that it may not work for me?

Code:
1.
export DEVKITPRO=/opt/devkitpro
export DEVKITARM=${DEVKITPRO}/devkitARM
export DEVKITPPC=${DEVKITPRO}/devkitPPC
export PATH=${DEVKITPRO}/tools/bin:$PATH

2.
cd ~
git clone --recursive https://github.com/switchbrew/libnx.git
cd libnx

3.
make all

4.
make install

5.
cd ~
git clone --recursive https://github.com/Atmosphere-NX/Atmosphere

6.
cd Atmosphere

7.
export DEVKITPRO=/opt/devkitpro
export DEVKITARM=/opt/devkitpro/devkitARM
export DEVKITPPC=/opt/devkitpro/devkitPPC

8
make -j$(nproc)
if you have all needed packages should work fine.

also step 7 is not necessary you only need that set of commands once by session.
 
  • Like
Reactions: Muxi

josete2k

Well-Known Member
Member
Joined
Apr 24, 2009
Messages
678
Trophies
1
Age
43
Location
Spain
XP
1,598
Country
Spain
I'm still with the haze error...

Code:
make[4]: *** No rule to make target '/home/josete2k/atmosphere/troposphere/haze/romfs/shaders/console_fsh.dksh', needed by '/home/josete2k/atmosphere/troposphere/haze/haze.nro'.  Stop.
make[4]: *** Waiting for unfinished jobs....
built ... haze.nacp
make[3]: *** [Makefile:182: build] Error 2
make[3]: Leaving directory '/home/josete2k/atmosphere/troposphere/haze'
make[2]: *** [Makefile:10: haze] Error 2
make[2]: Leaving directory '/home/josete2k/atmosphere/troposphere'
make[1]: *** [/home/josete2k/atmosphere/atmosphere.mk:136: troposphere] Error 2

But if I try with make again it compiles and finish... I assume that the haze nro should not be working...
 

impeeza

¡Kabito!
OP
Member
Joined
Apr 5, 2011
Messages
6,360
Trophies
3
Age
46
Location
At my chair.
XP
18,714
Country
Colombia
For me on the tests from last night,

MSYS, using make -j generates error and if you run again builds fine
MSYS, using make builds fine the first time but takes a lot of time.
MinGW64, using make -j builds fine the first time.

so may be something about timing on the build of different parts for the source.
 

Muxi

Well-Known Member
Member
Joined
Jun 1, 2016
Messages
605
Trophies
0
Age
52
XP
2,120
Country
Germany
I'm still with the haze error...
Is it maybe because you compile via Msys2 and not Msys2 MINGW64?
Post automatically merged:

On the past days the code has bend changing buy the hour, so it maybe work now and not working 30 minutes later
Does libnx then have to be recompiled each time, or is it sufficient to simply type "pacman -Syu"?
 

impeeza

¡Kabito!
OP
Member
Joined
Apr 5, 2011
Messages
6,360
Trophies
3
Age
46
Location
At my chair.
XP
18,714
Country
Colombia
Is it maybe because you compile via Msys2 and not Msys2 MINGW64?
Post automatically merged:


Does libnx then have to be recompiled each time, or is it sufficient to simply type "pacman -Syu"?
pacman -Syu updates the database from repositories servers and if there is a new version of a previously installed package is upgraded.

So far no new LibNX has been released, only the source code got some commits approved, in order to have the latest code of LibNX on your system you need to build and install manually each time a commit is made on the GitHub repository.

For that you need to run one of the next set of commands:

If the latest commits are made on the main branch:
Bash:
cd ~
rm -rf ~/libnx
git clone --recursive https://github.com/switchbrew/libnx.git
cd ~/libnx
make all -j$(nproc)
make install -j$(nproc)

If the latest commits are made on a PR:
Bash:
cd ~
rm -rf ~/libnx
git clone --recursive https://github.com/switchbrew/libnx.git
cd ~/libnx
git fetch origin pull/PR#/head
git checkout -b pullrequest FETCH_HEAD
make all -j$(nproc)
make install -j$(nproc)


Or if the latest commit are made on a Branch:
Bash:
cd ~
rm -rf ~/libnx
git clone --recursive https://github.com/switchbrew/libnx.git
cd ~/libnx
git checkout BRANCHNAME
make all -j$(nproc)
make install -j$(nproc)
 
  • Like
Reactions: Muxi

josete2k

Well-Known Member
Member
Joined
Apr 24, 2009
Messages
678
Trophies
1
Age
43
Location
Spain
XP
1,598
Country
Spain
Is it maybe because you compile via Msys2 and not Msys2 MINGW64?
Post automatically merged:


Does libnx then have to be recompiled each time, or is it sufficient to simply type "pacman -Syu"?
Nope... This time I'm compiling with MINGW64.
 
  • Wow
Reactions: impeeza

impeeza

¡Kabito!
OP
Member
Joined
Apr 5, 2011
Messages
6,360
Trophies
3
Age
46
Location
At my chair.
XP
18,714
Country
Colombia
Last edited by impeeza,
  • Like
Reactions: Muxi and josete2k

Muxi

Well-Known Member
Member
Joined
Jun 1, 2016
Messages
605
Trophies
0
Age
52
XP
2,120
Country
Germany
I have a question of understanding. I wanted to test compile AMS today (which is actually not necessary, since there are no new commits for version 1.6.2) and after selecting the active branch, the "make" command is no longer applicable. Does anyone have an explanation for this? Thanks in advance for any answers.
2023-10-28 12_48_58-~_libnx.png


2023-10-28 12_49_41-Branches · switchbrew_libnx · GitHub – Opera.png
 

impeeza

¡Kabito!
OP
Member
Joined
Apr 5, 2011
Messages
6,360
Trophies
3
Age
46
Location
At my chair.
XP
18,714
Country
Colombia
because gh-pages are the documentation of the proyect, that branch is no meant to be build nor have code.

get back to main branch.

the main branch got updated and later they updated the documentation.
 
  • Like
Reactions: Muxi

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • No one is chatting at the moment.
    K3Nv2 @ K3Nv2: Lol rappers still promoting crypto