2022-07-21 04:37 AM
As a project expands, scolling down the main.cpp file is slowing me down. So I wished to break down the main.cpp by selecting "Generate peripheral initialisation as a pair of '.c/.h'files" inside the ioc file-> project manager -> Code Generation ->Generated files. After compiling the generated code, the IDE shows:
undefined reference to `MX_FREERTOS_Init()'
make: *** [makefile:83: MX_FreeRTOS_test.elf] Error 1
The same issue exsits in an empty project, and the issue would not appear if the project is converted to a C project. I noticed that other peripheral files such as usart has a pair of .c/.h file, whereas freertos only has a .c file been generated. in a C project.
How can I fix this issue? Will this be fixed in later versions of cubeIDE?
2022-07-23 02:51 AM
I have fixed this error and figured out how MX_FREERTOS_Init() was meant to be used.
Noticed that:
It is suggested that cubeMX is letting the user implement the main body of the function. And indeed, by implementing this function in main.cpp, the error went away. To be specofic, I added the following:
MX_FREERTOS_init(){
//your init code to run before rtos starts
}
It would be nice if there were comments in the code to inform the user of the usage, instead of throwing an error at them.
2022-07-30 11:53 PM
After further investigation into the code, I realised my previous understanding was wrong. Instead, a simple fix is to rename the freertos.c to freertos.cpp
2022-08-03 09:04 AM
If you rename to .cpp, the next time you regenerate from the IOC file, a new freertos.c will be created. There needs to be a better solution.
2022-08-08 03:09 AM
Hello @xlin.1
First let me thank you for having reported.
I tried to reproduce the issue you faced but the projects I have generated compile without error ( the declaration and call for this function is ok MX_FREERTOS_Init() ).
PS : The test environment:
For further investigation could you precise which MCU you are using as well as the SW versions.
Thanks in advance.
Semer.
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2022-08-08 09:32 PM
Hi Semer
Thanks for looking into this issue. I have screen recorded this issue which can be viewed here:
In the video I created an empty project in a new workspace with latest cubeIDE updates installed. the following procedures are key:
You should see the build err. In the video I also showed that this err goes away if freertos.c is renamed freertos.cpp
I am hopping cubeIDE could work more smoothly with c++. As mentioned by BPete.1 it does involve more work to use c++ in the current cubeIDE.
Best
Peter