3.1.1 Driver Command-line Format

The xc8-cc 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 driver has the following basic command format:

xc8-cc [options] files

So, for example, to compile and link the C source file hello.c, you could use the command:

xc8-cc -mcpu=atmega3290p -O2 -o hello.elf hello.c

Throughout this manual, it is assumed that the compiler applications are in your console’s search path. See 3.1.2 Driver 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 3.6 Option Descriptions. Many of the command-line options accepted by xc8-cc are common to all the MPLAB XC compilers, to allow greater portability between devices and compilers.

The files can be any mixture of 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.