coderjoe.net

Me, myself, and my code.

Using the libnds example template Makefiles

30 July 2007

Of the different methods for setting up a project, using the provided template Makefiles is by far the easiest.

Packaged with the Nintendo DS examples package that you downloaded (you did download the examples package at my suggestion… didn’t you?) there is a directory called “templates”.

This directory contains a number of template project directories, each designed to make use of the environment variables set during the tool chain install step.

Using these templates is a very simple process. I will describe how to do this both in Linux and in Windows. Following in the grandest of programming traditions, lets call our project “helloworld”.

In Linux:

First lets create a directory for our project in our home directory:

    mkdir ~/helloworld

Next lets copy over the arm9 template ( I assume you’ve extracted the examples archive to your devkitPRO directory ):

    cp -R ${DEVKITPRO}/examples/templates/arm9/* ~/helloworld/

That’s all there is to it!

Each template already comes with a default main.c file containing the equivelent of a hello world application, so you’re ready to go!

To test it, change to the helloworld directory and type make.

    cd ~/helloworld/make

In Windows:

The instructions for Windows are almost identical to the instructions for Linux. The only differences between the two are really the Windows style commands and paths.

Create a new folder for your project.

Note: You must make sure that your project directory path does not contain any spaces!

For this reason I would suggest creating a directory under c:devkitPro called “projects” in which you will put all of your NDS Homebrew Projects.

Once the directory has been created, copy everything inside the directory “C:\devkitPro\examples\ndstemplates\arm9” into your new project directory.

To build your project open a command shell

Start -> Run -> Type “cmd” -> click ‘Ok’

Change directories to your project directory

    cd c:\devkitPro\projects\helloworld

type ‘make’

If all is set up correctly in either operating system, when your make process is complete you should find two files one called helloworld. nds and one called helloworld. ds. gba. These two files are for the different respective types of NDS Flash Carts.

If you boot up your new NDS program you will see the drunkencoders.com “Hello DS dev’rs” hello world app!

Congratulations, you have your first project.

For more information read the documentation provided with the example templates, and poke around the provided example code.