Well, I realize I had promised to give instructions for both Windows and Linux, but as it turns out, the instructions for Windows are so simple it’s almost laughable.
Are you windows users ready?
Installing devkitARM and setting up your environment in Windows.
That’s right. That’s it. You’re done Windows users. Now go have a coffee while us linux users get ourselves up and running.
Installing devkitARM and setting up your environment in Linux and Mac OSX.
To be honest, the process isn’t all that much more complex, but it does assume you know a little bit about setting environment variables.
The first thing you’ll need to do is make sure you’ve downloaded the devkitARM binary package, the libnds source package, and the example code package mentioned in the previous post.
Step 1) Setting up the directory structure:
First we need to set up a development path. This path can be anywhere, but for the sake of this tutorial we’ll assume you’re installing to /usr/local/devkitPRO/.
The first thing we need to do is create our directory structure: For now this is as simple as
mkdir /usr/local/devkitPRO
But by the time we’re finished it should look something like
/usr/local/devkitPRO /usr/local/devkitPRO/devkitARM/ /usr/local/devkitPRO/libnds/
Step 2) Installing the devkitPro binaries:
Next we’ll want to uncompress our devkitARM tar.bz2. Assuming you’ve downloaded the devkitARM archive to your home directory, this can be acomplished by changing to the devkitPRO directory we’ve just created and running:
cd /usr/local/devkitPRO/ tar -xjvf ~/devkitARM_r20-linux.tar.bz2
the devkitARM tar.bz2 contains a root directory called devkitARM which when compressed will contain the toolchain and a series of helpful binaries located within its “bin” directory.
Step 3) Decompress the libnds source:
Next we’ll need to decompress libnds. Unlike the devkitARM archive, libnds does not contain it’s own base directory, so we should create one for it now, and decompress to that directory.
mkdir /usr/local/devkitPRO/libnds cd /usr/local/devkitPRO/libnds tar -xzvf ~/libnds-20070503.tar.bz2
Now you have the source and tool chain necessary to build libnds into a fully fledged library for your linking pleasure. Unfortunately, if you’re at all familiar with Linux, you’ve likely already typed make, and to your surprise you’ve received a warning!
We need to set up some environment variables so the makefiles know where the tool chain and other libraries live.
Step 4) Set some environment variables:
First we need to set the DEVKITPRO variable to point to our devkitPRO install directory:
export DEVKITPRO=/usr/local/devkitPRO
Then we need to set DEVKITARM to point to our devkitARM install location
export DEVKITARM=${DEVKITPRO}/devkitARM
To make things easier for me, I just added the following three lines to the bottom of my ~/.bashrc file so every interactive shell would have access to these environment variables.
#Set Variables for DEVKIT_PRO export DEVKITPRO=/usr/local/devkitPRO export DEVKITARM=${DEVKITPRO}/devkitARM
Step 5) Compile libnds:
Now that we have our environment variable set, we can compile libnds. Just go back to our libnds directory and type make!
cd /usr/local/devkitPRO/libnds make
If all went well, you should see a bunch of text fly by, and eventually successful completion!
Step 6) Bake until golden brown:
Congratulations, you now have a successfully built Nintendo DS development tool chain and libraries.
If you’d like to test your toolchain you can extract the example source tarball that I suggested you download in the previous tutorial, and type make in it’s root directory. If everything is correctly set up, it should create a Nintendo DS ROM for each example in the examples directory.
The examples may not make much sense now, but make sure to poke around the examples. They’re one of the most useful resources a Nintendo DS homebrew developer has at his or her disposal.
Final Notes:
A final suggestion would be to install a Nintendo DS Emulator on your computer if you haven’t already. This way you can begin experimenting with your Nintendo DS examples even if you don’t yet have a DS or development hardware. However, when it comes to testing your shiny new Nintendo DS programs, nothing beats booting them on a Nintendo DS.
I would highly recommend that every budding Nintendo DS developer own at least one Nintendo DS. Besides… when you’re not developing you can pop in your Mario Kart or Tetris cartridge and enjoy Nintendo’s awesome handy-work!
Now that you have a working tool chain set up, you should go on to configure your IDE of choice to use devkitARM and libnds.
This entry was posted on Monday, July 23rd, 2007 at 10:37 pm and is filed under Coding. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site. Tags: devkitarm, devkitpro, libnds, nintendo-ds-homebrew, projects, tutorial
I can’t get either binary to compile. It says: gzip: stdin: not in gzip format tar: Child returned status 1 tar: Error exit delayed from previous errors Am I supposed to recompile the archive into .tar.gz?
I got armdevkit installed but libnds refuses to compile.
Hello Techforumz,
Thanks for reading. As it turns out there is a typo in my instructions.
“tar -xzvf” should be “tar -xjvf” (the -j flag is used with bzip2 compressed tar archives).
I’ll update the tutorial.
Happy hacking.
Ok, got it now, thanks.
Thanks for the posting.
What would you recommend about debugging? I’ve looked into Insight, which I can’t get to work satisfactorily, No$Cash is very expensive and I’m not sure if there’s any emulators with debug output windows.
Cheers
@cheese_block:
Yeah, No$Cash isn’t the cheapest option on the block, but for debugging I’ve heard you can’t beat it. As for free solutions you’ll just have to work with emulators and Insight.
If you find any better solutions please clue me in.
Thanks, and happy hacking.
[...] Setting up an NDS Homebrew tool chain in Linux and Mac OSX! (Ok… Windows too…) (tags: programming nds homebrew ds) Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages. [...]
Thanks for putting this post up! I think it might possibly be the only description of the required directory structure and environment variables for a Linux install of Devkitpro anywhere on the internet!
For anybody else finding this, note that you also need to extract libfat-nds into the libnds subdirectory (/usr/local/devkitPRO/libnds if you are using the paths in this guide) if you want libfat (and one of the NDS examples requires it be present to compile). I’m guessing that dswifi also goes into the libnds directory, but I’m not sure. According to this message on a mailing list that’s the case (“All the DS libraries should be installed in the libnds folder”): http://www.nabble.com/Re%3A-Problem-compiling-examples-in-Linux-p13417132.html
@anonymous:
You’re absolutely correct.
If you’re using the latest version of the source (it has changed a lot since this post was authored) then you do indeed need to place the libraries into the libnds directory.
Thanks for the tip.
How do you compile files? I tried typing Make, but it doesn’t work. It says “nothing to be done”. What do I type?
@Damien:
What do you mean by simple files? Are you looking for a GNU Make tutorial?
If so check this site out: http://www.cs.utah.edu/dept/old/texinfo/make/make_toc.html
If you’re just trying to compile one file at a time, don’t even bother with make. Just use gcc or cc as defined in the man page.
Cheers.
Now you can use the devkitpro buildscripts (URL below) to build the complete toolchain automatically from sources:
1. download the release “buildscripts 20080308″ (buildscripts-20080308.tar.bz2) from the sourceforge download page:
http://sourceforge.net/project/showfiles.php?group_id=114505
2. decompress: tar -xjvf buildscripts-20080308.tar.bz2
3. cd buildscripts; ./build-devkit.sh
See the README.TXT for details
for those MAC users, you will need to a couple more things:
1) install xcode from apple developers, it’s free just signup. http://developer.apple.com/Tools/xcode/ 2) install default.arm7 from the devkitpro files from sourceforge and put it in your libnds folder: http://sourceforge.net/project/showfiles.php?group_id=114505
Well I’am not able to compile anything after i did this setup. Every atemp to build something ends in
Nintendo DS rom tool 1.40 – Feb 20 2009 by Rafael Vuijk, Dave Murphy, Alexei Karpenko Cannot open file ‘/usr/local/devkitPRO/libnds/default.arm7′. make[1]: *** [/home/ganku/code/Demo3/Demo3.nds] Error 1 make: *** [build] Error 2
Exactly the same problem Nintendo DS rom tool 1.41 – May 1 2009 by Rafael Vuijk, Dave Murphy, Alexei Karpenko Cannot open file ‘/usr/local/devkitPro/libnds/default.arm7′. make[1]: *** [/home/rafa400/projects/chapter_0-starting_system/chapter_0-starting_system.nds] Error 1 rm moon.s splash.s planet.s orangeShuttle.s starField.s make: *** [build] Error 2
For those of you having trouble you can download the default.arm7 from the devkitpro files on sourceforge and just put it in your libnds folder (as mentioned above). Get it from here: http://sourceforge.net/project/showfiles.php?group_id=114505
@gemste A belated thanks for the heads up.
I am on a mac and tried to follow your instructions to the dot. I thought I had installed everything in the right way, but when I try to compile the helloworld example, I get Errors that say things are wrong with the code itself, like:
main.cpp arm-eabi-g++ -MMD -MP -MF /Users/Alex/Downloads/dsdev/nds-examples-20070127/Graphics/2D/hello_world/build/main.d -g -Wall -O2 -mcpu=arm9tdmi -mtune=arm9tdmi -fomit-frame-pointer -ffast-math -mthumb -mthumb-interwork -I/Users/Alex/Downloads/dsdev/nds-examples-20070127/Graphics/2D/hello_world/include -I/Users/Alex/Downloads/dsdev/nds-examples-20070127/Graphics/2D/hello_world/build -I/opt/local/devkitpro/libnds/include -I/opt/local/devkitpro/libnds/include -I/Users/Alex/Downloads/dsdev/nds-examples-20070127/Graphics/2D/hello_world/build -DARM9 -fno-rtti -fno-exceptions -c /Users/Alex/Downloads/dsdev/nds-examples-20070127/Graphics/2D/hello_world/source/main.cpp -o main.o /Users/Alex/Downloads/dsdev/nds-examples-20070127/Graphics/2D/hello_world/source/main.cpp:31:17: warning: nds.h: No such file or directory /Users/Alex/Downloads/dsdev/nds-examples-20070127/Graphics/2D/hello_world/source/main.cpp: In function ‘int main()’: /Users/Alex/Downloads/dsdev/nds-examples-20070127/Graphics/2D/hello_world/source/main.cpp:46: error: ‘touchPosition’ was not declared in this scope /Users/Alex/Downloads/dsdev/nds-examples-20070127/Graphics/2D/hello_world/source/main.cpp:46: error: expected ‘;’ before ‘touchXY’ /Users/Alex/Downloads/dsdev/nds-examples-20070127/Graphics/2D/hello_world/source/main.cpp:48: error: ‘irqInit’ was not declared in this scope /Users/Alex/Downloads/dsdev/nds-examples-20070127/Graphics/2D/hello_world/source/main.cpp:49: error: ‘IRQ_VBLANK’ was not declared in this scope /Users/Alex/Downloads/dsdev/nds-examples-20070127/Graphics/2D/hello_world/source/main.cpp:49: error: ‘irqSet’ was not declared in this scope /Users/Alex/Downloads/dsdev/nds-examples-20070127/Graphics/2D/hello_world/source/main.cpp:50: error: ‘irqEnable’ was not declared in this scope /Users/Alex/Downloads/dsdev/nds-examples-20070127/Graphics/2D/hello_world/source/main.cpp:51: error: ‘videoSetMode’ was not declared in this scope /Users/Alex/Downloads/dsdev/nds-examples-20070127/Graphics/2D/hello_world/source/main.cpp:52: error: ‘MODE_0_2D’ was not declared in this scope /Users/Alex/Downloads/dsdev/nds-examples-20070127/Graphics/2D/hello_world/source/main.cpp:52: error: ‘DISPLAY_BG0_ACTIVE’ was not declared in this scope /Users/Alex/Downloads/dsdev/nds-examples-20070127/Graphics/2D/hello_world/source/main.cpp:52: error: ‘videoSetModeSub’ was not declared in this scope /Users/Alex/Downloads/dsdev/nds-examples-20070127/Graphics/2D/hello_world/source/main.cpp:53: error: ‘VRAM_C_SUB_BG’ was not declared in this scope /Users/Alex/Downloads/dsdev/nds-examples-20070127/Graphics/2D/hello_world/source/main.cpp:53: error: ‘vramSetBankC’ was not declared in this scope /Users/Alex/Downloads/dsdev/nds-examples-20070127/Graphics/2D/hello_world/source/main.cpp:55: error: ‘SUB_BG0_CR’ was not declared in this scope /Users/Alex/Downloads/dsdev/nds-examples-20070127/Graphics/2D/hello_world/source/main.cpp:55: error: ‘BG_MAP_BASE’ was not declared in this scope /Users/Alex/Downloads/dsdev/nds-examples-20070127/Graphics/2D/hello_world/source/main.cpp:57: error: ‘BG_PALETTE_SUB’ was not declared in this scope /Users/Alex/Downloads/dsdev/nds-examples-20070127/Graphics/2D/hello_world/source/main.cpp:57: error: ‘RGB15′ was not declared in this scope /Users/Alex/Downloads/dsdev/nds-examples-20070127/Graphics/2D/hello_world/source/main.cpp:60: error: ‘u16′ was not declared in this scope /Users/Alex/Downloads/dsdev/nds-examples-20070127/Graphics/2D/hello_world/source/main.cpp:60: error: expected primary-expression before ‘)’ token /Users/Alex/Downloads/dsdev/nds-examples-20070127/Graphics/2D/hello_world/source/main.cpp:60: error: expected primary-expression before ‘)’ token /Users/Alex/Downloads/dsdev/nds-examples-20070127/Graphics/2D/hello_world/source/main.cpp:60: error: ‘consoleInitDefault’ was not declared in this scope /Users/Alex/Downloads/dsdev/nds-examples-20070127/Graphics/2D/hello_world/source/main.cpp:68: error: ‘swiWaitForVBlank’ was not declared in this scope /Users/Alex/Downloads/dsdev/nds-examples-20070127/Graphics/2D/hello_world/source/main.cpp:69: error: ‘touchXY’ was not declared in this scope /Users/Alex/Downloads/dsdev/nds-examples-20070127/Graphics/2D/hello_world/source/main.cpp:69: error: ‘touchReadXY’ was not declared in this scope make[1]: *** [main.o] Error 1 make: *** [build] Error 2
It hasn’t even started linking when I get the error.
same / similar problem to Tharo and 2Pedorretas:
linking hello_world.elf built … hello_world.arm9 Nintendo DS rom tool 1.46 – Dec 2 2009 by Rafael Vuijk, Dave Murphy, Alexei Karpenko failed to open input file make[1]: *** [/opt/devkitpro/examples/hello_world/hello_world.nds] Error 1 make: *** [build] Error 2
this was with the latest binary versions of the tarballs. this is on opensuse 11.1
Thanks to all! I fiddled with this for a bit tonight, and with your posts, I was able to get it working. I used the binaries for devkitARM, libnds, libfat-nds, and dswifi as well as the default-arm7. with: devkitPro |_devkitARM |_libnds | |_ | |_ | |_ |_examples
I am able to make most of the examples on 32 bit install of OpenSuse 11.1 on my laptop. The key for me was getting the default-arm7 into the libnds for the examples.
Again Many thanks!
Whoops… The sub lines didn’t display due to the less than’s. That should read: with: devkitPro |_devkitARM |_libnds | |_[libnds_untarred_here] | |_[libfat-nds_untarred_here] | |_[dswifi_untarred_here] | |_[default-arm7_here] |_examples
OK i’ve figured out the problem with linking hello_world.elf built … hello_world.arm9 Nintendo DS rom tool 1.46 – Dec 2 2009 by Rafael Vuijk, Dave Murphy, Alexei Karpenko failed to open input file make[1]: *** [/opt/devkitpro/examples/hello_world/hello_world.nds] Error 1 make: *** [build] Error 2
I hacked the living hell out of the ndstool and found out it is looking for default.elf I found it lying around in my /opt/devkitpro/ directory and i suspect that others will too.
Hope this helps
oops forgot to mention that it the default.elf file has to go into the libnds directory
It seems you must copy the default.elf AND default.arm7 into the libnds repository… (currently the default_arm7 aur package miss the .elf one)
This is a good guide, but it’s out of date since the devkitPro team has split up some of their packages into a few separate ones.
I have written a simple automated installer for Linux users (it should work on any distro), which can be found here: http://lmn.mooo.com/projects/devkitpro-sh The script can also install a few higher-level game libraries — PALib and uLibrary — and I intend to keep it up-to-date (working on a buildbot for nightly checks right now ).
Name (required)
Mail (will not be published) (required)
Website