This error, usually appearing as:
make: *** No rule to make target `../Path/To/HeaderFile.h', needed by `build/Embedded/production/_ext/_DOTDOT/Path/To/ObjectFile.o'. Stop. make: Leaving directory `/c/Project/Directory' make: *** [.build-conf] Error 2 make: 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.
- 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.