View Full Version : Is it possibe to use Lazarus fir NDS development

06-03-2010, 09:36 PM

I've installed and got v 2.4 fpc4nds compilig all the examples, and working on real hardware - so thanks!

(I've always given up on homebrew before as my C isn't so great - but I've been "doing" delphi development for the past 5 years or so, so this seems idea for me. Just a shame that your Wii port for fpc will not be progressed).

I was wondering it is possible to use Lazarus (or other front end may bloodshed-dev-pascal) that would give code-compeltion and would invoke the arm-fpc compiler? If so - any hints on how to do it? I miss the code completion/ide!


06-03-2010, 11:30 PM
Of course you can :)
You will need a Lazarus distro with fpc 2.4.0, maybe a 0.9.29 snapshot should be fine. In order to create a NDS project, please do the following steps:

1 Select Project->New project->Program
2 modify the code removing the unneded parts:

program Project1;
{$mode objfpc}
ctypes, nds9;



3 From the menu Project->Project options...->Compiler options select "NoGUI" as LCL widget type
4 move on Compiler options->Code then select "arm" as Target CPU and "nds" as Target OS
5 move on Compiler options->Other then check "Use additional Compiler Config file", writing the config file of your nds compiler (maybe something like c:\lazarus\fpc\2.4.0\bin\arm-nds\fpc.cfg). Lazarus will complain about some conflicting names, but just do ok and all will be fine ;)

6 From the menu Run->Run parameters...->Local->Host Application select your emulator with full path (something like c:\desmume\desmume.exe)
7 Put $ProjPath()\$NameOnly($ProjFile()).nds on "Command line parameters" field

The code completion feature should work fine now. Of course you can't debug, but you can build and run your nds app on the emulator just by pressing F9, as for win32 applications ;)

26-03-2010, 04:54 PM
Hi - thanks for the reply - but I can't get it working...

On my windows xp machine, I've installed
into C:\lazarus

I've also got
installed to C:\fpc4nds.

Are these the correct packages?

(Oh - and devkitpro in C:\devkitPro)

Using this config - lazarus kept saying that it couldn't find ppcarm.exe, so I copied
arm-nds folder from C:\fpc4nds\bin & C:\fpc4nds\units and placed these in C:\lazarus\fpc\2.4.0.

Your post seemed to suggest that this should be the directory structure.

When I try compiling this program

program helloworld;
{$mode objfpc}

uses nds9;


printf('Hello World !!!');

I get an information box, saying "unable to find file "".
If it belongs to your projectm check search path in project-<compiler options..-> ......

The message window logs :-

Error: ppcarm.exe can't be executed, error message: Failed to execute ""ppcarm.exe" -B -MObjFPC -Scghi -O1 -Tnds -gl -vewnhi -l -n @c:\lazarus\fpc\2.4.0\bin\arm-nds\fpc.cfg "-FiC:\temp\New Folder\lib\arm-nds\" -FuC:\lazarus\fpc\2.4.0\units\arm-nds\libndsfpc\ -FuC:\lazarus\fpc\2.4.0\units\arm-nds\ "-FuC:\temp\New Folder\" -Fu. "-FUC:\temp\New Folder\lib\arm-nds\" -oproject1 project1.lpr

Does the path to "ppcarm.exe" need to be in the "path" variable - or should lazaus work out where it is from (C:\lazarus\fpc\2.4.0\bin\arm-nds)

Whats also strange - is if in the IDE, I click "find declartion" on consoleDemoInit -
project1.lpr(4,11) Error: source not found: unit C:\lazarus\fpc\2.4.0\units\arm-nds\libndsfpc\nds9.ppu

BUT in C:\lazarus\fpc\2.4.0\units\arm-nds\libndsfpc\ there is nds9.ppu and nds9.o

When I click project options "TEST" - the top box displays

c:\lazarus\fpc\2.4.0\bin\i386-win32\fpc.exe -MObjFPC -Scghi -O1 -Tnds -Parm -gl -va -l -n @c:\lazarus\fpc\2.4.0\bin\arm-nds\fpc.cfg "-FiC:\temp\New Folder\lib\arm-nds\" -FuC:\lazarus\fpc\2.4.0\units\arm-nds\libndsfpc\ -FuC:\lazarus\fpc\2.4.0\units\arm-nds\ -Fu. -FUlib\arm-nds\ C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\testcompileropt ions.pas

And the bottom windows says ERROR: compiled FPC unit not found:,:-

And I definately DO have the target os as nds, target cpu as arm.

Any other ideas please?


I seem to think there was a wiki page for a lazarus console/gamers edition (can't find the link now) - which would have all this already configured. Any news on that?

26-03-2010, 06:07 PM
Try compiling it in a directory without spaces. I saw you used C:\temp\New Folder. The old release apparently had a few problems with that

10-04-2010, 08:07 AM
Thanks for the help - I've got it working now. (I needed to change the enviroment compiler to use c:\lazarus\fpc\2.4.0\bin\arm-nds\ppcarm.exe rather than c:\lazarus\fpc\2.4.0\bin\i386-win32\fpc.exe) and with the above instructions from Legolas its working now!

PS :
I've got a few screen shots/instructions of how I got it installed - I'll post the instructions here over the next week as it might help others new to the world of lazarus/fpc and targeting different cpus to get up and running.

10-04-2010, 06:58 PM
PS :
I've got a few screen shots/instructions of how I got it installed - I'll post the instructions here over the next week as it might help others new to the world of lazarus/fpc and targeting different cpus to get up and running.

Hey that'd be awesome. Also if you are interested in making a magazine article out of it I can see about putting it into issue 3 of Pascal Gamer Magazine. I'm always on the look out for some good solid articles like this.

Glad you got your platform setup now go show us some NDS games! :)

13-11-2010, 06:09 PM
I got it working too thanks

13-11-2010, 06:35 PM
the examples work except for the ones that need an include like texture.bin.inc
I have the texture.bin file but it needs to be texture.bin.inc
if i rename it I get errors

13-11-2010, 09:52 PM
Remember, you need to convert it into delphi code from binary data :)

There should be a tool that can do that. I cant remember the name. bin2inc or something

13-11-2010, 10:00 PM
texture.bin is converted in an include file by using the provided makefile:

set PATH=%PATH%;c:\fpc4nds\bin\arm-nds
make OS_TARGET=nds CPU_TARGET=arm BINUTILSPREFIX=arm-eabi- PP=ppcarm.exe

I don't know if "make" can be called by Lazarus; however you could call "make" the very first time, in order to generate the inc files, then use Lazarus as usual

13-11-2010, 11:59 PM
so the executable that makes the bin into an inc is in the arm-nds folder and it begins with arm-eabi ??

How do I make an image into a BIN file?

14-11-2010, 02:23 PM
No, there is a little neat program called bin2s, that produces assembly files from binaries (texture.bin.s), then the makefile uses a "trick" to generate a pascal include file (texture.bin.inc). In the last step it calls the assembler to make an object file (texture.bin.o) from texture.bin.s.

About your other question, grit or wingrit should do the trick :)