No Rule To Make Target

This error, usually appearing as:

make[2]: *** No rule to make target `../Path/To/HeaderFile.h', needed by `build/Embedded/production/_ext/_DOTDOT/Path/To/ObjectFile.o'.  Stop.
make[2]: Leaving directory `/c/Project/Directory'
make[1]: *** [.build-conf] Error 2
make[1]: Leaving directory `/c/Project/Directory'
make: *** [.build-impl] Error 2
BUILD FAILED (exit value 2, total time: 6s)

can mean several things. However, following are some of the main causes of this error -
  • In projects where making a change to a single header file can trigger changes in many other files in the project due to conditional compilation statements. In this situation, the regular Build or Debug buttons only build files that have been physically changed by you since the last build. In other words, you need make to rebuild all files in your project to ensure that conditional includes are picked up based on the one change you made to the header file.
To fix the problem, click the Clean and Build Main_Rebuild_Project.png button before you click the Debug Main_Debug_Project.png button.
  • If the source files are not in the parent directory and have been added from a path relative to the parent directory. These relative paths can get corrupted as a result of the project move or for some unforeseen reason and cause this error.

  • If you uninstall a compiler and install a newer version of the compiler, this error may occur.

To fix this problem, update your compiler paths to reflect the updated paths, from under the Tools > Options > Embedded > Build Tools > Toolchain menu, select the compiler and click OK. Then, set the desired compiler under File > Project Properties(projectname) > Compiler toolchain > Compiler.


Some other causes for this message are-

  • Locked files or access permissions problems with MPLAB® X project files
  • Missing or corrupted primary Makefile in a project (can be remedied by making a new project if the primary Makefile was accidentally deleted)
  • Specifying no build configuration, or an invalid build configuration (more likely to occur when writing your own make command line with CONF=configuration name)

MPLAB® X uses a primary Makefile which includes generated makefiles in a make. Generated makefiles may need to be regenerated, for example in the case of copying a project from one PC to another. This can be accomplished by going to the project properties, changing something (i.e. selected debugger), and clicking apply. If no changes are detected, the files will not be generated.

The build and dist directories within the MPLAB® X project contain intermediate and output files. You can safely erase them (although ALL intermediate files and output files for ALL build configurations for the project will be lost). To recreate them, you need to re-build each configuration. No permanent files are in the build or dist directory. One technique that may be employed to mitigate the 'No rule to make target' message is to delete the build and dist directories, followed by doing a clean and build for the new project configuration. This is generally a last recourse.

MPLAB® X should re-generate the makefiles when needed. If this does not happen, a small sample test case should be made to reproduce the problem, and that test case should be sent to Microchip Technical Support with concise instructions as to how to duplicate the problem so the issue can be identified and fixed.

© 2024 Microchip Technology, Inc.
Notice: ARM and Cortex are the registered trademarks of ARM Limited in the EU and other countries.
Information contained on this site regarding device applications and the like is provided only for your convenience and may be superseded by updates. It is your responsibility to ensure that your application meets with your specifications. MICROCHIP MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND WHETHER EXPRESS OR IMPLIED, WRITTEN OR ORAL, STATUTORY OR OTHERWISE, RELATED TO THE INFORMATION, INCLUDING BUT NOT LIMITED TO ITS CONDITION, QUALITY, PERFORMANCE, MERCHANTABILITY OR FITNESS FOR PURPOSE. Microchip disclaims all liability arising from this information and its use. Use of Microchip devices in life support and/or safety applications is entirely at the buyer's risk, and the buyer agrees to defend, indemnify and hold harmless Microchip from any and all damages, claims, suits, or expenses resulting from such use. No licenses are conveyed, implicitly or otherwise, under any Microchip intellectual property rights.