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

75 visualizaciones (últimos 30 días)
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?

Respuesta aceptada

MathWorks Support Team
MathWorks Support Team el 23 de Jun. de 2025
Editada: MathWorks Support Team el 23 de Jun. de 2025
The error "No rule to make target" is typically thrown by the make or gmake build automation tools when they cannot find instructions on how to create a specific file or target. This can happen for several reasons:

1. Incorrect File Path:

One common cause is an incorrect file path, particularly when the path contains white spaces. The make tool often struggles with paths that include spaces, which can result in the path being truncated in the error message. For example, you might see an error like:
make: *** No rule to make target 'C:/Projects/Electric', needed by 'model_source.o'. Stop.
To avoid this, it is generally recommended to use folder names without spaces in any software project.
If you must use paths with spaces, such as when specifying include or source directories in the Model Settings > Custom Code section, make sure to enclose the entire path in double quotes, like this:
"C:/Projects/Electric Motor Control"
For further guidance, refer to the MathWorks documentation on handling folder names with spaces:

2. Missing File:

Another possible cause is a missing file. If the build system references a file that does not exist at the specified location, it will throw this error. For instance:
gmake: *** No rule to make target 'E:/toolbox/target/codertarget/rtos/src/linuxinitialize.c', needed by 'linuxinitialize.c.o'. Stop.
This message suggests that the file linuxinitialize.c is not present at the given path. You should verify the file’s existence using File Explorer.
In some cases, such issues stem from a faulty installation of a support package. Reinstalling the package can often resolve the problem.
Additionally, if the model has been moved to a different location, it is important to delete all generated artifacts and code generation folders such as slprj and model_xxx before attempting a rebuild. Another potential issue could be undefined environment variables used by the makefile, such as MATLAB_WORKSPACE. If these variables are not set correctly, the resulting file paths may be invalid due to missing top-level directories.

3. Windows Character Length Limit

A third cause relates to the Windows operating system’s path length limitation. Windows imposes a maximum path length of 256 characters.
If your project directory structure is too deep or your file names are too long, this limit may be exceeded, resulting in the same error. To resolve this, consider shortening the reference model name or relocating your project to a directory with a shorter path.

4. Simulink Real-Time Character Length Limit

Finally, when working with Simulink Real-Time and Speedgoat hardware, you may encounter this error due to limitations in the third-party QNX compiler. For example:
make: *** No rule to make target '../../slprj/slrealtime/sltestProjectorController/instrumented/sltestProjectorController_rtwlib.a', needed by 'C:/Users/.../.../Test_Scenarios_slrealtime_rtw/Test_Scenarios'. Stop
This error can occur when all of the following conditions are met:
  1. The top-level folder name exceeds 75 characters.
  2. The model includes a referenced model.
  3. The reference model name is long enough that the relative library path (e.g., ../../slprj/slrealtime/<submodelname>/instrumented) exceeds 75 characters.
In such cases, reducing the length of the top-level folder name or the reference model name can help avoid the issue.

Más respuestas (0)

Categorías

Más información sobre Deployment, Integration, and Supported Hardware en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by