Microchip Technology SW006023-1N Data Sheet

Page of 238
Compiler Command Line Driver
 2012 Microchip Technology Inc.
DS51686E-page 51
Compile both files by typing the following at the prompt:
xc32-gcc 
-mprocessor=32MX795F512L 
-o ex1.out ex1.c add.c
This command compiles the modules ex1.c and add.c. The compiled modules are 
linked with the compiler libraries and the executable file ex1.out is created.
3.3.2
Multi-step C Compilation
Make utilities and IDEs, such as MPLAB IDE, allow for an incremental build of projects 
that contain multiple source files. When building a project, they take note of which 
source files have changed since the last build and use this information to speed up 
compilation.
For example, if compiling two source files, but only one has changed since the last 
build, the intermediate file corresponding to the unchanged source file need not be 
regenerated.
If the compiler is being invoked using a make utility, the make file will need to be con-
figured to use the intermediate files (.o files) and the options used to generate the 
intermediate files (-c, see Section 3.9.2 “Options for Controlling the Kind of Out-
put”
). Make utilities typically call the compiler multiple times: once for each source file 
to generate an intermediate file, and once to perform the second stage compilation.
For example, the files ex1.c and add.c are to be compiled using a make utility. The 
command lines that the make utility should use to compile these files might be 
something like:
xc32-gcc -mprocessor=32MX795F512L -c ex1.c
xc32-gcc -mprocessor=32MX795F512L -c add.c
xc32-gcc -mprocessor=32MX795F512L -o ex1.out ex1.o add.o
3.4
THE C++ COMPILATION SEQUENCE
3.4.1
Single-step C++ Compilation
A single command-line instruction can be used to compile one file or multiple files.
3.4.1.1
COMPILING A SINGLE C++ FILE
This section demonstrates how to compile and link a single file. 
For the purpose of this 
discussion, it is assumed the compiler's 
<install-dir>/bin
 directory has been 
added to your PATH variable. The following are other directories of note:
• <install-dir>/pic32mx/include/cpp the directory for standard C++ 
header files.
• <install-dir>/pic32mx/include/proc the directory for 
PIC32MXdevice-specific header files.
• <install-dir>/pic32mx/lib the directory structure for standard libraries 
and start-up files.
• <install-dir>/pic32mx/include/peripheral the directory for PIC32 
peripheral library include files.
• <install-dir>/pic32mx/lib/proc the directory for device-specific linker 
script fragments, register definition files, and configuration data may be found.