Building Projects in MPLAB® X IDE

Last modified by Microchip on 2023/11/10 11:04

The Build Process

MPLAB® X Integrated Development Environment (IDE) uses the GNU make program to control the build process. The make utility decides which files need to be built and then invokes the appropriate build tool (e.g., assembler, compiler, linker) for those files and their dependencies. make determines what needs to be built based on a script-like document called a makefile, which is generated by MPLAB X IDE to describe your project to the make utility.

Build Methods

There are several ways that make can build your code, based on which one of the following methods you use to start the build process.

Build Main Project

Build Main Project is the simplest of the build methods. All it does is call make, which will build any files within a project that have changed since the last build (uses the file timestamp). The first time it is invoked, it will build the entire project, but subsequent builds will be much faster for larger projects.

Clicking the small down arrow beside the icon provides options for this icon:

  • Build Project
    • Build the project and create the production image (HEX file).
  • Build for Debugging
    • Build the project and create the debug image (ELF file).
  • Build with PRO Comparison
    • If you use an MPLAB XC C compiler in Free mode, you can build in PRO mode as well and see a comparison output of differences, if any exist.

Clean and Build Main Project

Clean and Build Main Project deletes any intermediate files generated by previous builds and then invokes make to rebuild all files in the project, regardless of whether or not they have changed since the last build. Clicking the small down arrow beside the icon provides the same options as the Build Main Project icon.

Debug Main Project

Debug Main Project invokes make much like Build Main Project, but it links in additional code required by the debugger. After a successful build, it will automatically program the target device with the debug image (ELF file). When programming is complete, the debug session will start.

Run Main Project

Run Main Project is similar to Debug Main Project but it does NOT link in any debug code. It invokes make just like Build Main Project. Then after a successful build, it will automatically program the target device with the production image (HEX file), and then release the target device from reset so that it begins running autonomously. No debug functions are available in this mode.

Make and Program Device Main Project

Make and Program Device Main Project invokes make just like Build Main Project. Then after a successful build, it will automatically program the target device with the production image (HEX file). Click on the small down arrow beside the icon to see programming options. No debug code is linked in and no debug functions are available in this mode.

View the Build Process

The output of the build process can be viewed in the Output window.

output window

Customize the Build Process

You can customize the build process by right-clicking the Project name in the Projects window, scrolling to the bottom of the menu, and selecting Properties.

customize the build process

This selection will open the Project Properties dialogue box. This allows you to include/exclude files from the build process, change the device family pack and compiler versions used to build the project, change the target device, etc. Select Building from the left side categories to add macros to that run before or after the build process.

Project Properties Build Options tab