|
|
|
Home > Computing > Linux > Archos PMA430 (and other Archos AV) stuff > My first Qtopia application
My first Qtopia application -- how to get started with Qtopia development -- part 2
Last modified: Tue Nov 20 07:56:33 2007
A simple command-line program
Let's begin by developing a trivial, `Hello, world' application to
run at the Linux command prompt on the PMA430. Why? Well, this will
test that the cross-compiler toolchain is working, and demonstrate
how to test software without creating a full installer package.
Start by creating this simplest possible C++ program that produces
some output. I suugest the following:
#include <iostream.h>
int main(int argc, char **argv)
{
cout << "Hello, world!\n";
}
I'll assume you've called this source code `hello1.cpp'.
Compile this source to object code as follows:
/opt/Embedix/tools/bin/arm-linux-g++ -o hello1.o -c hello1.cpp
This should produce the file hello1.o. Then link this
with the standard libraries to produce an executable:
/opt/Embedix/tools/bin/arm-linux-g++ -o hello1 hello1.o
If you know about C/C++ development on Linux, you'll be aware that
you could do these two operations in a single step, but I want to
separate the compile and link phases so it will be clearer what's
going on later.
The linker produces the executable file hello1. If
you run the Linux
`file' utility on this exectuable, here's what you should see:
% file hello1
hello1: ELF 32-bit LSB executable, ARM, version 1 (ARM),
for GNU/Linux 2.0.0, dynamically linked (uses shared libs), not stripped
`Not stripped' means that the executable still contains debugging
information, which is why it's 300 kB long! This is a very big file
from a four-line program, so you need to do:
/opt/Embedix/tools/bin/arm-linux-strip hello1
Which brings the file size down to 62 kB. That's still a big file for
a four-line program, but you'll find that this file size increases
only very slightly until your program gets to about 1,000 lines of
code. Most of the overhead is in the startup and shutdown code.
It goes without saying that, in a real development exercise, you
wouldn't want to type all these commands at the prompt. You'd
create a shell script or, more usually, a Makefile. I'm not going
to describe this process here, since it's standard Unix programming
stuff, and nothing to do with Qtopia.
Your next job will be to get the hello1 program onto
the PMA430 for testing. My usual approach is to copy files onto
a local web server, then use the wget utility from the
PMA's command line. However, if you don't have a web server handy,
you can use the USB interface and transfer the program just as you
would any other file. Mount the PMA430 as an external drive, and
copy the hello1 program onto (for example) the
System directory.
From inside the PMA430, the directory that appears as
/System from a host computer appears as
/media/System, because the /media
directory represents the whole hard disk. So, to run
the program, you need to start the console program (using
the `Console' icon on the Applications tab of the launcher).
Then, at the prompt, type:
# chmod 755 /media/System/hello1
# /media/System/hello
Hello, World!
If you see `Hello, World!', it's worked. If you see anything else,
it hasn't. The chmod command may not be necessary --
it's purpose is to re-assign `execute' permission to the file, which
may have been lost in whatever process you used to copy it from the
host computer.
Go to part 3...
|
|
|
|
Shameless plug
|
 By the author of this site. Buy on-line from Amazon USA | UK
|
|