Quick guide to setting up PALib in OSX.

  • Download the correct version of devkitARM for your CPU architecture
  • Mount the DMG
  • Run the package and install to the default location
  • Download the latest stable version of PALib (make sure you get the zipped version)
  • Unzip the archive
  • Rename the resultant folder to “PAlib”
  • Open a Finder window and browse to /opt/local
  • Drag the “PAlib” folder into the Finder window - you will receive a prompt to authenticate yourself (click “Authenticate”), so type in your OSX password

That’s all of the files downloaded and installed. Next we need to start mucking about in the command line in order to replace devkitPro’s version of libnds with the version that ships with PALib.

  • Open a Terminal window
  • Type cd /opt/local/devkitPro
  • Type sudo mv libnds libnds_old
  • Enter your OSX password (the Terminal should prompt you with “Password:“)
  • Open a Finder window and browse to /opt/local/PAlib
  • Click on the “libnds” folder and press Command-C to copy it
  • Click on the desktop and press Command-V to paste a copy of the “libnds” folder
  • In the Finder, browse to /opt/local/devkitPro
  • Drag the copy of the “libnds” folder from the desktop to the Finder window (authenticate when prompted by entering your OSX password)

That’s all of the files set up. Now we need to add the PALib environment variable to OSX.

  • Load the file “~/.profile” into a text editor - if you have Smultron installed (and if not, you should do - it’s great) you can type this in the Terminal:

    /Applications/Smultron.app/Contents/MacOS/Smultron ~/.profile

  • Add the following line to the end of the file (you will have to type your OSX password in when saving):

    export PAPATH=“/opt/local/PAlib/PAlib”

Nearly done now. The last thing we need to do is comment out a couple of bugs in the DS Motion card code - you probably don’t need to do this if you’re working in C, and you definitely shouldn’t do this if you need to use the motion functionality (you’ll need to wait for a proper fix in that case):

  • Open the file “/opt/local/PAlib/PAlib/include/nds/arm9/PA_Motion.h”
  • Comment out line 23
  • Change line 29 to return 0;

That, I think, should be everything. Note that this is correct at the time of writing, using devkitPro r20 and PALib 070717.


ant on 2007-10-19 at 08:46 said:

Thanks - I wondered where the environment variables were stored. I’ve updated the post to reflect the fact that typing the “export” command into the terminal doesn’t actually update the .profile file. The devkitPro and devkitARM variables are set up by the devkitARM installer automatically, which is handy.

The only problem I can see with the NDSLIBPATH variable is that, should you distribute your code, anyone wanting to compile it will need to add that variable in too.

Jeff on 2007-10-19 at 09:35 said:

Actually, I had to set a number of other environment variables, so I edited by ~/.profile to include the following:

devkitPro variables

export DEVKITPRO=“/Developer/NDS” export DEVKITARM=“$DEVKITPRO/devkitARM” export PAPATH=“$DEVKITPRO/PAlib” export NDSLIBPATH=“$DEVKITPRO/libnds” export PATH=“$PATH:$DEVKITARM/bin”

Note that I put all my NDS stuff in a single directory under /Developer/NDS - I may well have done the wrong thing with NDSLIBPATH so don’t quote me exactly.

ant on 2007-10-19 at 10:44 said:

I’m working on a template project at the moment that’ll work with the setup instructions I posted. Just got to get a couple of things tidied up and it’s done.

Jeff on 2007-10-19 at 11:22 said:

The only place NDSLIBPATH was used was in the standard makefiles. But you are right, it is an issue. However, I think that if you are distributing libraries, you pretty much need to either (a) rely on common usage (ala the standard PALib makefiles) or (b) document your requirements.

For example, you’ll note that I used $DEVKITPRO/libnds instead of repeating the full pathname over and over in each of the environment variables - that way, it can all be redirected with a single-line edit.

I’ve been using an XCODE project some of the time - its pretty easy to setup. As I recall, it was something like:

a) create an ‘empty’ project b) duplicate the standard file structure from a PALIB template into the project folder. c) create a new target, using ‘External Target’ d) add a File Group referencing the various source files (to make the editor easier to use) e) edit the Project Info (right-click the topmost node in the project tree and set the Cross-Develop Using Target SDK: popup to Other. I’ve set it to /Developer/NDS/PAlib/ -- you can’t use the environment variable in here, sadly because the .profile only affects Terminal session. f) in the Build panel, I have set SDK Path to /Developer/NDS/PALib g) I’ve also got Header Search Paths including $(SDKROOT)/include/nds

(These last two imply that you leave the libnds stuff under the PALib directory rather than moving it up one, I think)

If you like, use Add Executable to attach a copy of DesMume.app which is “out there on the net” though not in a very usable state, you have to manually select your .nds file over every time, the Recent Items menu doesn’t work.

Most of the time, however, I find it easier to use make from the Terminal because XCODE gets a bit confused about error results - it doesn’t seem to clear out previous build errors when you hit Build and it looks like you aren’t fixing stuff. If you Clean before you Build, it seems to work but that defeats the purpose of ‘make’.

Finally, as to where Environment Variables are set, I have a Prefs Panel called RCEnvironment (http://www.rubicode.com/Software/RCEnvironment/) which allows you to set session-wide variables (that would show up in XCODE, etc), but I didn’t use it here precisely because of the “telling other people what they need to do” - RCEnvironment hides stuff away a bit too much, I’ve definitely forgotten I had it a couple of times now.

ant on 2007-10-19 at 12:22 said:

Hmm, I hope they’ve improved Code Sense in XCode 3, because, after all that fiddling, it’s a little too crap in version 2 for me to switch from VC++.

ant on 2007-10-23 at 22:00 said:

Nicely spotted, thanks. Updated!

Jim on 2007-10-23 at 22:25 said:

woohoo! nice tutorial, worked great…

One of the paths was wrong for the file you have to editr: Open the file “/opt/local/PAlib/include/nds/arm9/PA_Motion.h”

should be: Open the file “/opt/local/PAlib/PAlib/include/nds/arm9/PA_Motion.h”

darren on 2008-01-24 at 23:17 said:

Just tried this tutorial with PAlib 070717 and devkitPro r21 but when I got to build the helloworld template sample I get an error. main.c arm-eabi-g++ -g -mthumb-interwork -mno-fpu -L/opt/local/devkitPro/PAlib/lib -specs=ds_arm9.specs main.o -L/opt/local/devkitPro/PAlib/lib -lpa9 -L/opt/local/devkitPro/libnds/lib -lnds9 -o build.elf /opt/local/devkitPro/devkitARM/bin/../lib/gcc/arm-eabi/4.1.2/../../../../arm-eabi/lib/ds_arm9_crt0.o: In function CIDLoop': ds_arm9_crt0.s:(.init+0x2ac): undefined reference toinitSystem’ collect2: ld returned 1 exit status make[1]: *** [/Users/dazzarutgers/Documents/test/test.elf] Error 1 make: *** [build] Error 2

I dont know the reference to CIDLoop so Maybe a simple solution? Any help would be greatly appreciated

ant on 2008-01-25 at 09:56 said:

PALib doesn’t work with devkitPro r21. This is apparently being worked on as part of the next update. I think that there are a few workarounds on the PALib forum at http://www.palib.info - searching there should turn up something useful. Alternatively, you can downgrade back to r20.