Microchip Technology SW006023-2N Data Sheet

Page of 238
MPLAB
®
 XC32 C/C++ COMPILER
USER’S GUIDE
 2012 Microchip Technology Inc.
DS51686E-page 45
Chapter 3.  Compiler Command Line Driver
3.1
INTRODUCTION
The command line driver (xc32-gcc or xc32-g++) is the application that can be 
invoked to perform all aspects of compilation, including C/C++ code generation, 
assembly and link steps. Even if you use an IDE to assist with compilation, the IDE will 
ultimately call xc32-gcc for C projects or xc32-g++ for C++ projects.
Although the internal compiler applications can be called explicitly from the command 
line, using the xc32-gcc or xc32-g++ driver is the recommended way to use the 
compiler as it hides the complexity of all the internal applications used and provides a 
consistent interface for all compilation steps.
This chapter describes the steps the driver takes during compilation, files that the driver 
can accept and produce, as well as the command line options that control the com-
piler’s operation. It also shows the relationship between these command line options 
and the controls in the MPLAB IDE Build Options dialog.
Topics concerning the command line use of the driver are discussed below. 
3.2
INVOKING THE COMPILER
The compiler is invoked and runs on the command line as specified in the next section. 
Additionally, environmental variables and input files used by the compiler are discussed 
in the following sections.
3.2.1
Driver Command Line Format
The compilation driver program (xc32-gcc) compiles, assembles and links C and 
assembly language modules and library archives. The xc32-g++ driver must be used 
when the module source is written in C++. Most of the compiler command line options 
are common to all implementations of the GCC toolset (MPLAB XC16 uses the GCC 
toolset; XC8 does not). A few are specific to the compiler.
The basic form of the compiler command line is:
xc32-gcc [options] files 
xc32-g++ [options] files
For example, to compile, assemble and link the C source file hello.c, creating the 
absolute executable hello.elf,execute this command:
xc32-gcc -o hello.elf hello.c