STM32 NUCLEO fatal error: No such file or directory #include "main.h"

87 次查看(过去 30 天)
When I connect NUCLEO-F411RE and try to create code, the compiler gives me an error:
C:/ST_simulink/test_ert_rtw/test.h:21:18: fatal error: main.h: No such file or directory
#include "main.h"
Indeed, such a file is not created. I repeat as shown in the examples, but I can’t even start code generation. What's my problem?

回答(2 个)

Umar
Umar 2024-6-30,15:04
Hi Anton,
To resolve this error and enable successful code generation for NUCLEO-F411RE, you need to create the missing "main.h" file in your project directory. Here is an example of how you can create a basic "main.h" file:
% Create main.h file
fid = fopen('main.h', 'w');
fprintf(fid, '#ifndef MAIN_H\n#define MAIN_H\n\n#endif /* MAIN_H */\n');
fclose(fid);
By running this code snippet in Matlab, you will generate a simple "main.h" file that includes the necessary header guards to prevent multiple inclusions.
Hope this will help resolve your problem.

Saurav Shandilya
Saurav Shandilya 2024-7-9,6:08
编辑:Saurav Shandilya 2024-7-9,6:15
Based on screenshot, issue seems to be Build Toolchain. You are using MingGW64 which is primarily used to compile for native Windows applications. In Current case, we are trying to compile for ARM based MCU. Hence you should use GNU Tools for ARM Embedded Processors. I tried the same, and build goes fine. Refer below screenshot.
There are getting started example. You use them to test your setup and get a boiler plate to start with.
  • Example for Simulink Coder Support Package for STMicroelectronics Nucleo Boards
  • Example for Embedded Coder Support Package for STMicroelectronics STM32 Processors
Thanks,
Saurav

Community Treasure Hunt

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

Start Hunting!

Translated by