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

296 visualizzazioni (ultimi 30 giorni)
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?

Risposta accettata

MathWorks Support Team
MathWorks Support Team il 6 Feb 2024
Modificato: MathWorks Support Team il 6 Feb 2024
The error "No rule to make target" is typically thrown by the make/gmake build automation tool because it can't find the instructions on how to create a particular file or target. This can happen for several reasons:
(1) Incorrect Path:
Your project path, source file path and/or include folder path contains white spaces that the "make" tool cannot handle. You will notice that the path is cut off after or before the first white space in the error message. For example:
make: *** No rule to make target 'C:/Projects/Electric',
needed by 'model_source.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:
"C:/Projects/Electric Motor Control"
For more information, see the section "Troubleshooting Errors When Folder Names Have Spaces" on the following page:
(2) Missing File:
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) Windows Character Length Limit:
A long directory path name could also violate the 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.
(4) Simulink Real-Time Character Length Limit:
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/sltestProjectorController_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 by Speedgoat hitting the character length limit when all the following conditions are met.
1. The top folder name is >75 char.
2. The model has a reference model.
3. The reference model name is long enough such that the relative library path '../../slprj/slrealtime/<submodelname>/instrumented' string is >75 char.

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by