1.3. PRC-Tools

This tutorial shows you how to use the PRC-Tools to create a simple Palm OS application. It is the second of two possible tutorials that you can read through. The PRC-Tools development environment has a great price (its free) and it well loved by many a C programmer. Just like CodeWarrior, we have made sure that you can easily use it in conjunction with the source code and examples in the rest of the book (all the code has been compiled within both environments).

Here is what this PRC-Tools tutorial describes:

1.3.1. What PRC-Tools includes

The most important things are:

GCC

GNU C Compiler (GCC), which compiles C/C++ code to Motorola 68K. It also functions as a linker.

Build-PRC

This builds a PRC file from the code and the resources.

GDB

A source-level debugger.

After we cover installation for all platforms, we will deal with creating a project.

1.3.2. Installing on Windows

The official distribution location for PRC-Tools is http://prc-tools.sourceforge.net. Complete instructions are found at http://prc-tools.sourceforge.net/install/cygwin.html. As you are following the instructions, make sure that you select to install all four of the following packages: prc-tools, prc-tools-htmldocs, pilrc, and make.

1.3.3. Installing On x86 RPM-based Linux

The official distribution location for PRC-tools is http://prc-tools.sourceforge.net. If you are using an x86 RPM-based Linux, you can follow the directions at http://prc-tools.sourceforge.net/install/rpm.html.

1.3.4. Installing On Mac OS X

Complete instructions are found at http://www.zenonez.com/prctoolsx/.

1.3.5. Installing On Unix

The official distribution location for PRC-tools is http://prc-tools.sourceforge.net. Our instructions are for installing PRC-tools 2.1, the latest version at the time this was written.

Here are the instructions for installation.

1.3.5.1. Installing PRC-Tools

The PRC-Tools is the development environment itself.

  1. Otherwise, you'll need to do a build from the source. Download, uncompress and build: http://prdownloads.sourceforge.net/prc-tools/prc-tools-2.1.tar.gz

1.3.5.2. Installing the 4.0 SDK

The SDK contains the headers and libraries needed for Palm OS development.

  1. Download the 4.0 SDK from: www.palmos.com/dev/tools/sdk40.html

    1. Download "Palm OS SDK Core Components"

    2. Uncompress the tar file with:

      cd /opt/palmdev
      tar -zxf sdk40-core.tar.gz 
    3. Remove the unneeded files and rename to the needed directory names:

      rm -rf Documentation "Palm OS SDK Licenses"
      mv "Palm OS Support" sdk-4.0
      cd sdk-4.0
      mv Incs include
      mv "GCC Libraries" lib

  2. This 4.0 SDK is now installed as /opt/palmdev/sdk-4.0. To make that the default (used if no specific SDK is specified), execute:
    cd /opt/palmdev
    palmdev-prep --default 4.0

1.3.5.3. Installing PilRC

PilRC is the resource compiler; the last piece needed for development.

  1. Install PilRC. The current version is 2.9. Download pilrc_src.tgz from: www.ardiri.com/palm/download.php?file=pilrc_src.tgz Download it to /usr/local/src (or some other desired location).

  2. Uncompress it with:

    tar -zxf pilrc_src.tgz
  3. The line endings for the files are DOS-style. This can cause problems for compilers. Fix it by changing the files to Unix-style line endings with this script:

    cd pilrc-2.8
    for fnam in *.*
    do
      tr -d '\r' < $fnam > /tmp/foo
      cat /tmp/foo > $fnam
    done
  4. There's a problem with a declaration of strdup in pilrc.c. Comment out its declaration:

    //char *strdup(const char *s);
  5. Now, you're ready to build and make:

    ./configure
    make pilrc
  6. Install by copying to /usr/local/bin (or some directory of your choice):

    cp pilrc /usr/local/bin

1.3.6. Installing OReilly sample project

This section of the tutorial is for for users of PRC-Tools on all platforms.

We know our job is to make things as simple as possible for you. As a result, we imagine that when you create a new project you would like it to be as easy as can be expected. So, presto, we have made life easier. We've created a new, very simple project that has the correct structure of a Palm OS application, but that doesn't actually do very much. That way, it's easier to use as the basis of a new application.

Download this project from: www.calliopeinc.com/stationery.html.

1.3.7. Cloning the Sample Project

Duplicate the OReillyStationery directory:

cp -r OReillyStationery MyProject

Build the project by doing a make:

cd MyProject
make

The result can be found in the GCC/OReillyStarter.prc.

1.3.8. Customizing the output file

To change the output file, edit the Makefile, changing the value of the APP variable:

APP=MyProject

In addition, rename the .def file

mv OReillyStarter.def MyProject.def

Now, when you make, the resulting prc can be found in GCC/MyProject.prc

1.3.9. A non-debug build

If you'd like to build without debugging, change the CFLAGS definition in the Makefile from:

CFLAGS = -palmos4.0 $(DEBUGCFLAGS)

to:

CFLAGS = -palmos4.0 $(RELEASECFLAGS)