Introduction to the Cross-Platform Development Process241
8.1.3Native and Cross Compilers
A native compiler generates code for the same machine on which it is running. A cross
compiler generates code for a machine different from the one on which it is running.
8.1.4Cross Platform Development Cycle
The cross-platform development cycle consists of at least four stages. These stages are:
•Writing code
•Cross compilation
•Transferring binaries to the target
•Debugging
The steps may be different in some cases depending upon the type of product you are build-
ing. Figure 8-1 shows these processes and machines on which a particular process is carried out.
Let us take a closer look on these steps.
8.1.4.1Writing Code
When you write code for cross compilation, you have to keep few things in mind. The
CPU architecture of the target machine may be different from that of the host machine. This
means that you have to consider word lengths, byte order and so on. For example, length of inte-
ger may be different on the target machine. Similarly, organization of memory may play an
important role. As an example, the organization of bytes inside a 32-bit integer is different in
Intel CPUs as compared to Motorola CPUs. This is a typical network-byte-order problem and
must be considered when developing network protocols.
Some libraries’ routines may be different for cross compilers than for native compilers.
8.1.4.2Building on the Host Machine
After writing the code, you need to compile it on the host machine. In addition to a cross
compiler and cross assembler that can generate code for the target machine, you need libraries
that are linked to your code. These libraries are usually specific to the target machine and are
cross-compiled.
If you are writing code according to some standard, your porting process is usually very
quick. For example, if you have written libraries strictly using the ANSI standard, it will be rela-
tively easy for you to port these libraries from one platform to another. In most large software
development projects, it is important that you stick to some standard. This is because ultimately
you may wish to port and sell the product for many platforms.
You have learned the difference between static and dynamic linking earlier in this book.
Usually in cross compiling, you have to build the executable code with static linking because
you may not have shared libraries available on the target system. This is especially true for
embedded systems where you usually don’t have a large secondary storage device.
Next Page >>
<< Previous Page
Back to the Table of Contents