COMPILING AND LINKING A C/C++ PROGRAM
This page provide instructions on how to compile, assemble,
and link a source file written in C/C++. The compiler, assembler, and linker
programs are available in both UNIX and PC platform.
The commands for the compiler, assembler, and linker in
the UNIX environment is similar to those under the PC platform:
-
COMPILATION: To compiler a C/C++ program, simply execute the
TMS320C30 compiler.
leto_[1]: cl30 filename.c
The compiler automatically compiles and assembles the source
file and creates an object file: filename.obj.
-
LINKING: The next step
is to link the object file to produce an executable file in a linked
common-object file format (COFF). This format is popular in Unix-based
systems for easier modular programming and managing code segments.
This would generate
an output executable file called a.out for both the debugger and the
simulator. Either the .obj file must previously exist from a
compilation, or you have created the .cmd file manually.
leto_[1]: lnk30 filename.obj
leto_[1]: lnk30 filename.cmd
An example of a linker command file is shown below:
/*MATRIXC.CMD - LINKER COMMAND FILE */
-c /*using C convention */
-stack 0x100 /*256 words stack */
matrixc.obj /*object file */
-O matrixc.out /*executable output file */
-l rts30.lib /*run-time library support*/
MEMORY
{
RAMS: org=0x809800, len=0x2 /*boot stack */
RAM0: org=0x809802, len=0x3FE /*internal block 0*/
RAM1: org=0x809C00, len=0x3C0 /*internal block 1*/
}
SECTIONS
{
.text: {} > RAM0 /*code */
.cinit: {} > RAM0 /*initialization tables*/
.stack: {} > RAM1 /*system stack */
}