5.1.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 XC32 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 executable file hello.elf
,execute this command:
xc32-gcc -o hello.elf hello.c
Or, to compile, assemble and link the C++ source file hello.cpp, creating the executable file hello.elf
, execute:
xc32-g++ -o hello.elf hello.cpp
The available options are described in 5.7 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. Typically archive files are specified after
source files. The file types are described in 5.1.3 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.