Difference between revisions of "Setting up Development Environment"

From 3dbrew
Jump to navigation Jump to search
(→‎Unix-like platforms: Change SourceForge link to GitHub link for Perl installer)
m
 
(39 intermediate revisions by 15 users not shown)
Line 1: Line 1:
 
= Setup =
 
= Setup =
* Install [http://devkitpro.org/ devkitARM]. If it's already installed, update it.
+
Install [https://devkitpro.org/ devkitARM]. If it's already installed, update it using sudo (dkp-)pacman -Syu. On Windows, there's a [https://github.com/devkitPro/installer/releases/latest graphical installer]. On Unix-like platforms such as Linux/macOS, there's [https://github.com/devkitPro/pacman/releases/latest pacman]..
** On Windows, there's a [http://sourceforge.net/projects/devkitpro/files/Automated%20Installer/ graphical installer].
 
** On Unix-like platforms such as Linux/macOS, there's a [http://sourceforge.net/projects/devkitpro/files/Automated%20Installer/devkitARMupdate.pl/download Perl script]. Make sure you also select libctru and the 3ds examples when installing.
 
* Depending on the kind of homebrew you want to develop, you may be interested in installing and using additional libraries and tools which don't ship alongside devkitARM/libctru. A list of them can be found in [[Homebrew Libraries and Tools]].
 
  
 
==Windows==
 
==Windows==
devkitPro provides Win32-native precompiled versions of devkitARM which can be run directly on Windows.
+
* If you already use msys2 then you can follow the instructions at https://github.com/devkitPro/pacman/releases/latest to add the devkitPro repositories.
* [http://sourceforge.net/projects/devkitpro/files/Automated%20Installer/ download the latest version of the graphical installer] from SourceForge and run it, following the instructions as you go.
+
 
 +
Otherwise
 +
 
 +
* [https://github.com/devkitPro/installer/releases/latest download the latest version of the graphical installer] from github and run it, following the instructions as you go.
 
* An Internet connection is required.
 
* An Internet connection is required.
* You will want to make sure devkitARM is selected during the installation process to develop for the 3DS (and also the DS and GBA) - you can also install devkitPPC (for GameCube/Wii development) and devkitPSP (for PlayStation Portable development) if you wish.
+
* Ensure at least "3DS Development" is ticked - you can also leave the other options ticked if you wish.
 
* Once the installer has finished, launch MSYS from:
 
* Once the installer has finished, launch MSYS from:
 
** Windows 7 and earlier: Start -> All Programs -> devkitPro -> MSYS
 
** Windows 7 and earlier: Start -> All Programs -> devkitPro -> MSYS
Line 16: Line 16:
 
** Windows 10 (post-Anniversary Update): Start -> devkitPro -> MSYS
 
** Windows 10 (post-Anniversary Update): Start -> devkitPro -> MSYS
  
Alternatively starting with Windows 10 Anniversary Update (Version 1607), the [https://msdn.microsoft.com/en-us/commandline/wsl/install_guide Windows Subsystem for Linux (WSL)] may also be used to run the Linux version of devkitARM. Due to the fact that GCC was originally designed for Unix-like platforms its use may yield performance and convenience improvements. For instructions on how to set up devkitARM under WSL refer to the ''Unix-like platforms'' section. For WSL installation instructions, see the MSDN page linked just above, but ignore the part about having to be a Windows Insider; as long as you have the Anniversary Update or later it will work just fine.
+
Alternatively starting with Windows 10 Anniversary Update (Version 1607), the [https://msdn.microsoft.com/en-us/commandline/wsl/install_guide Windows Subsystem for Linux (WSL)] may also be used to run the Linux version of devkitARM. Unless you have some particular need for WSL it's recommended that you stick to a more standard environment.  
  
 
==Unix-like platforms==
 
==Unix-like platforms==
Currently devkitPro provides precompiled versions of devkitARM for the following Unix-like platforms: Linux (x86/x64), macOS (universal binary). Note that Linux x64 binaries are usable under WSL.
+
Currently devkitPro provides precompiled versions of devkitARM for the following Unix-like platforms: Linux (x86_64), macOS (x86_64). Note that Linux x86_64 binaries are usable under WSL.
 
 
* First, you need to install curl so the installer can download the devkitARM packages, and you should also install Git - you'll need it to update ctrulib or share your code on GitHub, among many other things.
 
 
 
* Find your way into a shell (eg. by opening a Terminal window), and follow the instructions for your OS:
 
** Debian/Ubuntu/Linux Mint/WSL: <code>sudo apt-get install git curl</code>
 
** Fedora/CentOS/RHEL: <code>sudo yum install git curl</code>
 
** openSUSE: <code>sudo zypper install git curl</code>
 
** macOS: Download Git from [http://git-scm.com/download/mac] and install it. Curl is included with the OS.
 
 
 
* Next, we need to download, make executable and run the devkitARM updater (don't worry, the updater is also the installer.)
 
<pre>
 
curl -L https://raw.githubusercontent.com/devkitPro/installer/master/perl/devkitARMupdate.pl -o devkitARMupdate.pl
 
chmod +x ./devkitARMupdate.pl
 
sudo ./devkitARMupdate.pl /opt/devkitpro
 
</pre>
 
  
* Finally, we need to tell your shell where to find the devkitARM binaries.
+
* Follow the instructions to install pacman found at https://github.com/devkitPro/pacman/releases/latest
<pre>
+
* run sudo (dkp-)pacman -S 3ds-dev to install the tools and libraries for 3ds development
echo "export DEVKITPRO=/opt/devkitpro" >> ~/.bashrc
+
* logout and login again to get the environment settings needed.
echo "export DEVKITARM=/opt/devkitpro/devkitARM" >> ~/.bashrc
 
echo "export PATH=$PATH:/opt/devkitpro/devkitARM/bin" >> ~/.bashrc
 
source ~/.bashrc
 
</pre>
 
  
 
= Building the examples =
 
= Building the examples =
3DS examples are still being created; however, there are a growing number of examples available from the [https://github.com/devkitPro/3ds-examples devkitPro/3ds-examples GitHub repository].
+
3DS examples are still being created; however, there are a growing number of examples available from the [https://github.com/devkitPro/3ds-examples devkitPro/3ds-examples GitHub repository]. These are downloaded by the installer and can be found in $DEVKITPRO/examples/3ds
There are now too many to list here in detail, so go ahead and browse them.
 
 
 
* To download these, if you installed Git (as you will have if you followed the above instructions), simply type <code>git clone https://github.com/devkitPro/3ds-examples.git</code> into your shell in the directory you wish to store the 3ds-examples folder in.
 
** To overwrite the (almost certainly outdated) examples installed by the devkitPro updater, type <code>git clone https://github.com/devkitPro/3ds-examples.git $DEVKITPRO/examples/3ds</code>.
 
  
 
These can be built from the command line.
 
These can be built from the command line.
Line 56: Line 33:
 
  cp -r $DEVKITPRO/examples/3ds/templates/application '''~/projects/my3dsproject'''
 
  cp -r $DEVKITPRO/examples/3ds/templates/application '''~/projects/my3dsproject'''
 
  cd '''~/projects/my3dsproject'''
 
  cd '''~/projects/my3dsproject'''
 +
 +
The standard Makefile will use the folder as the name of the 3dsx that will be built. You can keep that behaviour or simply change the <code>TARGET := $(notdir $(CURDIR))</code> line in the Makefile to explicitly name your project.
  
 
To compile it, type <code>make</code> in the project directory.
 
To compile it, type <code>make</code> in the project directory.
To run it on your 3DS, start the Homebrew Launcher, press Y to open the network loader, then on your PC type: <code>$DEVKITARM/bin/3dslink -a '''192.168.X.X''' '''my3dsproject'''.3dsx</code>, replacing '''192.168.X.X''' with your 3DS's IP address (displayed in the network loader screen) and '''my3dsproject''' with the name of the folder your project is in (ie. the folder you have the source folder in and the README file.)
 
Don't type the full path, just the last segment - eg. for <code>C:\a\b\'''verygood3dsapp'''</code>, you would type <code>'''verygood3dsapp'''.3dsx</code>.
 
 
If all goes well, you'll soon see your application running on your 3DS.
 
  
==Building the examples on Linux with Netbeans==
+
==Running your code==
* Go to File->New Project...
+
To run it on your 3DS, start the Homebrew Launcher, press Y to open the network loader, then on your PC type: <code>$DEVKITPRO/tools/bin/3dslink  '''my3dsproject'''.3dsx</code>, replacing '''my3dsproject''' with the name of the 3dsx file you want to run.)
* Select C/C++ Project with existing code
 
* Navigate to the examples directory and select the folder for the project you want to build; eg.    /home/vtsingaras/3ds/examples/app_launch
 
* Leave Configuration Mode to 'Automatic' and click 'Finish'.
 
* It will fail to build. Now edit Makefile and insert these two lines, adjusting for your devkitpro path, at the top:
 
<pre>export DEVKITPRO=/opt/devkitpro
 
export DEVKITARM=/opt/devkitpro/devkitARM</pre>
 
* Right-click the project and go to Properties->Code Assistance and click C Compiler.
 
* In include directories enter
 
<pre>/opt/devkitpro/devkitARM/include;/opt/devkitpro/ctrulib/libctru/include</pre>
 
adjusting again for your devkitPro path.
 
* Do the same for 'C++ Compiler'.
 
* Go to 'Run' and click 'Clean and Build Project'.
 
* Now right-click on the project and select Code Assistance->Reparse Project.
 
  
Now you can use Netbeans' code completion feature and build your project from the Run menu.
+
If all goes well, you'll soon see your application running on your 3DS. If not, it could help to add <code>-a '''ipaddress'''</code>, replacing '''ipaddress''' with the ip address of the console (visible on homebrew launcher after pressing Y).
  
= Building homebrew for distribution =
+
= Troubleshooting =
To build your homebrew, open a Bash shell as described above, browse to the folder of the homebrew you wish to compile, and run <code>make</code>.
+
'''I get the "Please set DEVKITARM in your environment." error.'''
  
* This will build a .elf file and a .3dsx file (the homebrew executable itself) together with a .smdh file (the icon).
+
Ensure you have the devkit-env package installed - (dkp-)pacman -Sl | grep devkit-env. Logout and login to get the enviroment settings.
** The Homebrew Launcher can only run homebrew in the 3DSX format, and can only display SMDH icons.
 
  
* To build a CCI (.3ds) file, you need to strip the .elf file and use makerom on it (with the provided RSF file):
+
For WSL users, you need to close the Bash shell, then reopen it for WSL to reload all of the variables from a clean state.
arm-none-eabi-strip '''[ELF file]'''
 
makerom -f cci -o '''[.3ds file]''' -rsf '''[RSF file]''' -target t -exefslogo -elf '''[ELF file]''' -icon '''[icon file]''' -banner '''[banner file]'''
 

Latest revision as of 12:31, 20 July 2023

Setup[edit]

Install devkitARM. If it's already installed, update it using sudo (dkp-)pacman -Syu. On Windows, there's a graphical installer. On Unix-like platforms such as Linux/macOS, there's pacman..

Windows[edit]

Otherwise

  • download the latest version of the graphical installer from github and run it, following the instructions as you go.
  • An Internet connection is required.
  • Ensure at least "3DS Development" is ticked - you can also leave the other options ticked if you wish.
  • Once the installer has finished, launch MSYS from:
    • Windows 7 and earlier: Start -> All Programs -> devkitPro -> MSYS
    • Windows 8 and 8.1: Right click on the Start screen and select 'All Apps'. You should find MSYS there.
    • Windows 10 (pre-Anniversary Update): Start -> All Apps -> devkitPro -> MSYS
    • Windows 10 (post-Anniversary Update): Start -> devkitPro -> MSYS

Alternatively starting with Windows 10 Anniversary Update (Version 1607), the Windows Subsystem for Linux (WSL) may also be used to run the Linux version of devkitARM. Unless you have some particular need for WSL it's recommended that you stick to a more standard environment.

Unix-like platforms[edit]

Currently devkitPro provides precompiled versions of devkitARM for the following Unix-like platforms: Linux (x86_64), macOS (x86_64). Note that Linux x86_64 binaries are usable under WSL.

Building the examples[edit]

3DS examples are still being created; however, there are a growing number of examples available from the devkitPro/3ds-examples GitHub repository. These are downloaded by the installer and can be found in $DEVKITPRO/examples/3ds

These can be built from the command line.

To start a new homebrew project from the bash shell, simply type the following (replacing ~/projects/my3dsproject with the place you would like your project to be stored, with ~ meaning your HOME directory):

cp -r $DEVKITPRO/examples/3ds/templates/application ~/projects/my3dsproject
cd ~/projects/my3dsproject

The standard Makefile will use the folder as the name of the 3dsx that will be built. You can keep that behaviour or simply change the TARGET := $(notdir $(CURDIR)) line in the Makefile to explicitly name your project.

To compile it, type make in the project directory.

Running your code[edit]

To run it on your 3DS, start the Homebrew Launcher, press Y to open the network loader, then on your PC type: $DEVKITPRO/tools/bin/3dslink my3dsproject.3dsx, replacing my3dsproject with the name of the 3dsx file you want to run.)

If all goes well, you'll soon see your application running on your 3DS. If not, it could help to add -a ipaddress, replacing ipaddress with the ip address of the console (visible on homebrew launcher after pressing Y).

Troubleshooting[edit]

I get the "Please set DEVKITARM in your environment." error.

Ensure you have the devkit-env package installed - (dkp-)pacman -Sl | grep devkit-env. Logout and login to get the enviroment settings.

For WSL users, you need to close the Bash shell, then reopen it for WSL to reload all of the variables from a clean state.