Why do I get the build error "No rule to make target"?

1.179 views (last 30 days)
I am trying to build my model using one of the workflows supported by coder products such as Simulink Coder, Embedded Coder or Simulink Real-Time. However, I encounter the error "No rule to make target". What does this error mean?

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 7 Feb 2023
Edited: MathWorks Support Team on 7 Feb 2023
This is an error message that is thrown by the "make" (make/gmake) command. Two common causes for this error message are the following:
(1) Your project path, source file path and/or include folder path contains white spaces that "make" cannot handle. You will notice that the path is cut off after the first white space in the error message. For example:
make: *** No rule to make target 'C:/Projects/Electric', needed by 'slrealtime_datatype_ground.o'. Stop.
It is recommended to avoid paths with white spaces in any software project. If you indicate include or source paths in the Model Configuration Parameters > Custom Code section, make sure to enclose the directory path with double quotes:\n
"C:/Projects/Electric Motor Control"
For more information, see the section "Troubleshooting Errors When Folder Names Have Spaces" on the following page:
https://www.mathworks.com/help/rtw/ug/enable-build-process-for-folder-names-with-spaces.html#bu6lx34
(2) It could also mean that the indicated file is missing. For example:
gmake: *** No rule to make target `E:/toolbox/target/codertarget/rtos/src/linuxinitialize.c', needed by `linuxinitialize.c.o'. Stop.
This could mean that the file "linuxinitialize.c" does not exist at the given location. Verify the existence of this file using File Explorer.
In the above case, the indicated file was missing as a result of a faulty Support Package installation. A clean re-installation of the support package resolved the issue.
Another possible reason could be that the model location was changed. Make sure to delete all artifacts and code generation folders (slprj, model_xxx) before you attempt a rebuild.
It is also possible that environment variables used by the makefile (ex: MATLAB_WORKSPACE) may not be defined on the system where the build is carried out. This may be the case if the file path shown in the error message is invalid due to missing top-level directories. 
(3) If you receive the following 'No rule to make target' error when running the model in Simulink Real-Time,
make: *** No rule to make target
'../../slprj/slrealtime/sltestProjectorController/instrumented/sltestProjectorContr
oller_rtwlib.a', needed by
'C:/Users/.../.../Test_Scenarios_slrealtime_rtw/Test_Scenarios'. Stop
the error could be due to the third-party QNX compiler used in Speedgoat hitting the character length limit when all the following conditions are met.
1. The top folder name should be >75 char
2. The model should have a reference model
3. The reference model name should be long enough such that relative library path '../../slprj/slrealtime/<submodelname>/instrumented' string should be >75 char."
(4) A long directory path name could also violate Windows 256-character length limit and result in this error.
To resolve the issue, reduce the length of the reference model name or start your project in a directory that has a shorter path name.

More Answers (0)

Categories

Find more on Deployment, Integration, and Supported Hardware in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by