We'll now go through the steps necessary to build a simple Neutrino system that runs on a standard PC and prints out the text "Hello, world!" — the classic first C program.
Let's look at the spectrum of methods available to you to run your executable:
If your environment is: | Then you can: |
---|---|
Self-hosted | Compile and link, then run on host |
Cross-development, network filesystem link | Compile and link, load over network filesystem, then run on target |
Cross-development, debugger link | Compile and link, use debugger as a "network filesystem" to transfer executable over to target, then run on target |
Cross-development, rebuilding the image | Compile and link, rebuild entire image, reboot target. |
Which method you use depends on what's available to you. All the methods share the same initial step — write the code, then compile and link it for Neutrino on the platform that you wish to run the program on.
The "Hello, world!" program itself is very simple:
#include <stdio.h> int main (void) { printf ("Hello, world!\n"); return (0); }
You compile it for PowerPC (big-endian) with the single line:
qcc -V gcc_ntoppcbe hello.c -o hello
This executes the C compiler with a special cross-compilation flag, -V gcc_ntoppcbe, that tells the compiler to use the gcc compiler, Neutrino-specific includes, libraries, and options to create a PowerPC (big-endian) executable using the GCC compiler.
To see a list of compilers and platforms supported, simply execute the command:
qcc -V
If you're using an IDE, refer to the documentation that came with the IDE software for more information.
At this point, you should have an executable called hello.