5.1.1 Driver Command-line Format
The xc32-gcc
driver can be used to compile and assemble
C and assembly source files, as well as link object files and library archives to form a
final program image.
The xc32-g++
driver must instead be used when the module source is
written in C++.
The driver has the following basic command format:
xc32-gcc
[options] files
So, for example, to compile and link the C source file
hello.c
, you could use the command:
xc32-gcc
-mprocessor=32MZ2048ECH100 -O2 -o hello.elf hello.c
The format for the C++ driver is similar.
xc32-g++
[options] files
And this driver is used in a similar way, for example:
xc32-g++
-mprocessor=32MZ2048ECH100 -O2 -o hello.elf hello.cpp
Throughout this manual, it is assumed that the compiler applications are in your console’s search path. See 5.1.2 Environment Variables for information on the environment variable that specifies the search locations. Alternatively, use the full directory path along with the driver name when executing the compiler.
It is customary to declare options
(identified by
a leading dash “-
” or double dash “--
”) before the files’
names; however, this is not mandatory.
Command-line options are case sensitive, with their format and description
being supplied in 5.7 Driver Option Descriptions.
Many of the command-line options accepted by xc32-gcc
are common to all the MPLAB XC compilers, to allow
greater portability between devices and compilers.
The files
can be any mixture of C/C++ and assembler source files, as well as relocatable object
files and archive files. While the order in which these files are listed does not directly
affect the operation of the program, it can affect the allocation of code or data. Note,
that the order of the archive files will dictate the order in which they are searched, and
in some situations, this might affect which modules are linked in to the program.
It is recommended that C-only projects use the xc32-gcc
driver. If you have C++ source code or
a mix of C and C++ source, always use xc32-g++
driver to ensure the correct libraries are linked
in.