introduction
In this article I show how to set up Microsoft Visual Studio 2008 to use the devkitARM compiler to create applications for the Nintendo DS. After you have read this article, you are able to use Visual Studio 2008 to build, rebuild, clean and execute your Nintendo DS application.
Visual Studio 2008 Express can be downloaded for free at microsoft.com, you want to have the C++ edition: Download Visual C++ 2008 Express Edition.
prerequisites
I assume you already have devkitARM and Visual Studio 2008 installed and both function correctly. I further assume you have a project that you want to migrate from e.g. VisualHAM, Programmers Notepad, etc… to Visual Studio, so I use the hello world example from libnds as existing project reference, which is located in devkitPro\examples\nds\hello_world.
create new visual studio project
We need to create an empty makefile project. You can find this in Visual Studio 2008 under Main menu -> New -> Project:
Select the project template and target location:
Rather than selecting the hello_world directory, we specify its parent, because Visual Studio creates a sub directory in the specified location with the specified name. This configuration will save the project file directly in the existing hello_world directory.
Click OK to continue.
configure new project
A new dialog pops up, the New Project Wizard:
Just click Next here to move on to the next page.
The following page looks more like fun! Settings specified in this New Project Wizard can be changed at any time in the Project Settings as well:
Please note that none of these settings have influence on the build process: Output, Preprocessor definitions, Include search path, Forced include files, CMR assembly search path and Forced using .NET assemblies.
We set Preprocessor definitions so Visual Studio knows which ARM9/ARM7 #if’s to syntax highlight differently. This is not passed to devkitARM.
We set Include search path so Visual Studio knows where to look for the libnds headers to provide code completion and intellisense, it will not add it to the search path used by devkitARM.
Here is an example what code completion and intellisense look like, first code completion:
The remaining commands in the New Project Wizard are what you typically use when working via the command prompt or shell. Now click Finish to complete the Wizard.
The New Project Wizard closes and Visual Studio shows an empty workspace now:
add files to project
It’s essential to know that Visual Studio will just invoke the commands specified in the New Project Wizard to build the project.
Compiling and linking your Nintendo DS application is entirely handled by devkitARM, NOT Visual Studio!
Visual Studio is only the graphical front-end that triggers these devkitARM build processes and serves as code editor.
The devkitPro makefile system has a feature to add directories that are supposed to contain source code to the so called SOURCES variable. All source files in those directories, added to this variables, are being compiled and considered during the link process.
Copied from devkitPro\examples\nds\hello_world\Makefile:
1 2 3 4 5 6 7 8 9 10 | #--------------------------------------------------------------------------------- # TARGET is the name of the output # BUILD is the directory where object files & intermediate files will be placed # SOURCES is a list of directories containing source code # INCLUDES is a list of directories containing extra header files #--------------------------------------------------------------------------------- TARGET := $(shell basename $(CURDIR)) BUILD := build SOURCES := gfx source data INCLUDES := include build |
This means that source files don’t get compiled when you add them to the Visual Studio project, but when you store them in the source directory of your file system!
add files to project, really
Now that you know your files don’t get compiled when you only add them to the Visual Studio Project, let’s really add them. You can do this via drag&drop operations from the Windows Explorer or via the Visual Studio Project context menu:
A new “File Open” dialog appears, which you have to navigate to your source files, select them and click Add. I recommend you add the makefile too.
Once done, your Visual Studio Project should look similar to this:
compile project
The magic moment has arrived, to compile the project you can use the Build sub-menu from the mainbar or hit CTRL+SHIFT+B:
When everything is configured properly, the project should build just fine and the output looks like:
1 2 3 4 5 6 7 8 9 10 11 12 | 1>------ Build started: Project: hello_world, Configuration: Debug Win32 ------ 1>Performing Makefile project actions 1>main.cpp 1>arm-eabi-g++ -MMD -MP -MF /c/devkitPro/examples/nds/hello_world/build/main.d -g -Wall -O2 -march=armv5te -mtune=arm946e-s -fomit-frame-pointer -ffast-math -mthumb -mthumb-interwork -I/c/devkitPro/examples/nds/hello_world/include -I/c/devkitPro/examples/nds/hello_world/build -I/c/devkitPro/libnds/include -I/c/devkitPro/libnds/include -I/c/devkitPro/examples/nds/hello_world/build -DARM9 -fno-rtti -fno-exceptions -c /c/devkitPro/examples/nds/hello_world/source/main.cpp -o main.o 1>linking hello_world.elf 1>built ... hello_world.arm9 1>Nintendo DS rom tool 1.41 - May 1 2009 1>by Rafael Vuijk, Dave Murphy, Alexei Karpenko 1>built ... hello_world.nds 1>Build log was saved at "file://c:\devkitPro\examples\nds\hello_world\Debug\BuildLog.htm" 1>hello_world - 0 error(s), 0 warning(s) ========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ========== |
compile project, the Vista barrier
I use Microsoft Vista and have to run Visual Studio 2008 as administrator, otherwise it outputs this error:
1 2 3 4 5 6 7 8 9 | 1>------ Build started: Project: hello_world, Configuration: Debug Win32 ------ 1>Performing Makefile project actions 1> 0 [main] us 0 init_cheap: VirtualAlloc pointer is null, Win32 error 487 1>AllocationBase 0x0, BaseAddress 0x71110000, RegionSize 0x2C0000, State 0x10000 1>c:\devkitPro\msys\bin\make.exe: *** Couldn't reserve space for cygwin's heap, Win32 error 0 1>Project : error PRJ0019: A tool returned an error code from "Performing Makefile project actions" 1>Build log was saved at "file://c:\devkitPro\examples\nds\hello_world\Debug\BuildLog.htm" 1>hello_world - 1 error(s), 0 warning(s) ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== |
If you encounter the same problem, see if it fixes the problem when you start Visual Studio 2008 with administrator privileges. You can do this when you right-click the Visual Studio 2008 startmenu entry and select “Run as administrator”.
add a rebuild target
We specified “make rebuild” in the New Project Wizard, but this target does not exist by default, so we have to create it first. Basically it should perform:
1 2 | make clean make |
Open the makefile and add this below clean:
1 | rebuild: clean $(BUILD) |
Select Build -> Rebuild Solution and see the output if it’s performing correctly.
add run target
So far we were able to compile, clean and rebuild the Nintendo DS project out of Visual Studio, but how to run it? We use a software emulator! I use no$gba to run my Game Boy Advance and Nintendo DS applications, so I want Visual Studio to start no$gba as well!
We do this like we did with rebuild, we add a new target to makefile which is responsible to start and pass the filename to the Nintendo DS emulator, in my case no$gba.
Put this below our earlier added rebuild target:
1 2 | run: $(BUILD) $(DEVKITPRO)/utilities/nogba/nogba.exe $(TARGET).nds |
The tab at the beginning at the 2nd line is important and must not be removed, you also want to modify the path to where the emulator of your choice is located.
Now open the Visual Studio Project Properties:
Select Debugging in the following dialog and fill out the Command and Command Argument text boxes:
Confirm the dialog with OK and select Debug -> Start Debugging, the project should build and start in the specified emulator!
Visual Studio compatible build messages
All build messages are redirected to the Visual Studio output “Build” pane. Warnings and errors include the filename and line number, but those are in the GCC format and when you double click them, Visual Studio is smart enough to open this file, but not to go to the line.
1 | 1>c:/devkitPro/examples/nds/hello_world/source/main.cpp:17: error: expected constructor, destructor, or type conversion before 'void' |
Double clicking this line opens main.cpp, but keeps the cursor at line 1.
Fortunalety, Jasper ‘cearn’ Vijn once had a regular expression on his website that transforms GCC messages in to Visual Studio format and I was clever enough to make a backup before the information went offline:
1 | 's/\(\w\+\):\([0-9]\+\):/\1(\2):/' |
We can redirect the build output to sed.exe (stream editor), which uses this regular expresssion to transform and output the text so Visual Studio can handle it.
We do this by extending the commands earlier specified in the New Project Wizard.
In the following dialog select NMake and modify the settings as shown below:
Build Command line:
1 | make 2>&1 | sed -e 's/\(\w\+\):\([0-9]\+\):/\1(\2):/' |
Rebuild All Command line:
1 | make rebuild 2>&1 | sed -e 's/\(\w\+\):\([0-9]\+\):/\1(\2):/' |
If you have never seen this 2>&1 before, it’s called command redirection operator and a feature of Microsoft Windows. >& writes the output from one handle to the input of another handle. Next comes |, the pipe operator. It takes the output of one command and directs it into the input of another command.
Confirm the Project Properties Dialog with OK, add an invalid line of code to one source file and build. The error message should look like this now and is clickable:
1 | 1>c:/devkitPro/examples/nds/hello_world/source/main.cpp(17): error: expected constructor, destructor, or type conversion before 'void' |
we are done
Happy compiling!
















I tried the above but Visual Studio refused to build and came up with an error which said that nakefile not found.
Any ideas please. Thanks, Mike
Does the “makefile” file exists in the project directory and can you compile from the command prompt? This is important to know to decide whether it’s a Visual Studio related problem.
If it compiles from the command prompt, open “Tools -> Options -> Projects and Solutions -> VC++ Directories” inside Visual Studio and try if it helps when you modify “Executables files” as followed:
1) Move $(PATH) to the top
2) Add “c:\devkitpro\mysys\bin”
In case the project does not compile from the command prompt, I’d try an example from libnds (devkitpro/examples/libnds). If even this fails to build, I’d probably give it a try to reinstall devkitARM.
Hope it helps, let me know!
Thanks Peter,
I really can’t see what is going wrong.
Yes, this small project will make just fine when done from the command prompt.
All I have done is to start a VC++ project and added the code and makefile in from the devkitpro folder.
Then, when I try to build I get the following error :-
1>—— Build started: Project: FirstNDS, Configuration: Debug Win32 ——
1>Performing Makefile project actions
1>make: *** No targets specified and no makefile found. Stop.
1>Project : error PRJ0019: A tool returned an error code from “Performing Makefile project actions”
1>Build log was saved at “file://c:\Documents and Settings\michael.HOMEOFFICE\My Documents\Visual Studio 2008\NDS\FirstNDS\FirstNDS\Debug\BuildLog.htm”
1>FirstNDS – 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Any more ideas ? Thanks, Mike.
Hey Mike,
I guess spaces in the project path can cause trouble. I can at least not compile a makefile project that contains space characters in its path. Could be worth to try to move the project to a non-space containing path and retry. Otherwise, have you followed the article step-by-step and used the helloworld project, does this work?
Hello again, Peter,
No !
I did NOT follow your original article precisely step-by-step without any modifications.
I have now done that and everything works wonderfully.
I thought that I had made only a minor change from your tutorial but it was obviously very significant.
What I did was to start a new project in a new folder (NOT in the devkitpro folder ! ) and then added the existing .CPP file and makefile into that project by using VC++ ‘Add Existing File’ menu. Let’s face it, this is what I would normally do – I can’t expect to keep on relying on there being an existing demo folder.
However, this seems to make a real difference to the way that visual studio runs. Can you please help me to make VC++ work on a brand new NDS project rather than use an existing demo. Just where are the differences in your setup procedures.
Thanks, Mike.
Hello again Peter,
Another problem with your tutorial ( and this time I HAVE strictly followed your instructions ! ).
When trying to do a debug, VC++ first of all comes up with a dialog, saying build not done. Then it comes up with an error, saying do debugging information not available for ‘make.exe’ . Then, when I say continue, it eventually carries on and finds the emulator OK.
Net result is that I do finally reach nogba but only after forcing VC++.
Any ideas ? Thanks, Mike
I think the answer may be Mike,
to go back to DSGM and have my IDE do the hard stuff for you?
[...] console-dev.de » Blog Archive » create nintendo ds applications with visual studio 2008 (tags: homebrew development ds programming nintendo) [...]
Hello,
I followed the instructions given on the article and I got the build working even on VS2005.
Unfotunately I can’t debug the example, due to the error already posted by Michael Mossman…
Add A Comment