Microchip Technology SW006023-2N Data Sheet

Page of 238
MPLAB
®
 XC32 C/C++ Compiler User’s Guide
DS51686E-page 46
 2012 Microchip Technology Inc.
Or, to compile, assemble and link the C++ source file hello.cpp, creating the 
absolute executable hello.elf, execute: 
xc32-g++ -o hello.elf hello.cpp
The available options are described in Section 3.9 “Driver Option Descriptions”. It 
is conventional to supply options (identified by a leading dash “-” before the 
filenames), although this is not mandatory.
The files may be any mixture of C/C++ and assembler source files, relocatable 
object files (.o) or archive files. The order of the files is important. It may affect the 
order in which code or data appears in memory or the search order for symbols. Typi-
cally archive files are specified after source files. The file types are described in 
Section 3.2.2 “Input File Types”.
Libraries is a list of user-defined object code library files that will be searched by the 
linker, in addition to the standard C libraries. The order of these files will determine the 
order in which they are searched. They are typically placed after the source filenames, 
but this is not mandatory.
It is assumed in this manual that the compiler applications are either in the console’s 
search path, the appropriate environment variables have been specified, or the full path 
is specified when executing any application.
Environment Variables
The variables in this section are optional, but, if defined, they will be used by the 
compiler. The compiler driver, or other subprogram, may choose to determine an 
appropriate value for some of the following environment variables if they are not set. 
The driver, or other subprogram, takes advantage of internal knowledge about the 
installation of the compiler. As long as the installation structure remains intact, with all 
subdirectories and executables remaining in the same relative position, the driver or 
subprogram will be able to determine a usable value. The “XC32” variables should be 
used for new projects; however, the “PIC32” variables may be used for legacy projects.
 
Note:
Command line options and file name extensions are case sensitive.
TABLE 3-1:
COMPILER-RELATED ENVIRONMENTAL VARIABLES
Option
Definition
XC32_C_INCLUDE_PATH
PIC32_C_INCLUDE_PATH
This variable’s value is a semicolon-separated list of directories, 
much like PATH. When the compiler searches for header files, it 
tries the directories listed in the variable, after the directories 
specified with -I but before the standard header file directories.
If the environment variable is undefined, the preprocessor 
chooses an appropriate value based on the standard installation. 
By default, the following directories are searched for include 
files:
<install-path>\pic32mx\include
XC32_COMPILER_PATH
PIC32_COMPILER_PATH
The value of PIC32_COMPILER_PATH is a semicolon-separated 
list of directories, much like PATH. The compiler tries the directo-
ries thus specified when searching for subprograms, if it can’t 
find the subprograms using PIC32_EXEC_PREFIX.