2020-10-26 07:05 AM
Hi,
In order to compile FreeRTOS in C++, I did a makefile that compile FreeRTOS in C (to avoid void* issue not recognized by C++), and the other files with C++ including stm32h7xx_it.c on cpu Cortex-M7.
Whatever the options of compilation I am using (shared library of mixed compilation between C and C++), I have the same issue on some files like stm32h7xx_it.c.
It does not recognize the functions embedded inside the C file.
Examples of issues are described here:
Creating FreeRTOS lib ....
Linking output ELF file to OBJECTS ....
***/tools/windows/9-2020-q2-update/bin/../lib/gcc/arm-none-eabi/9.3.1/../../../../arm-none-eabi/bin/ld.exe: out_cm7/obj/Applications/CM7/src/stm32h7xx_it.o: in function `prvGetRegistersFromStack(unsigned long*)':
stm32h7xx_it.c:(.text+0x64): undefined reference to `prvGetRegistersFromStack'
***/tools/windows/9-2020-q2-update/bin/../lib/gcc/arm-none-eabi/9.3.1/../../../../arm-none-eabi/bin/ld.exe: libFreeRTOS.a: undefined reference to `ulApplicationGetNextSequenceNumber'
***/tools/windows/9-2020-q2-update/bin/../lib/gcc/arm-none-eabi/9.3.1/../../../../arm-none-eabi/bin/ld.exe: libFreeRTOS.a: undefined reference to `vApplicationGetIdleTaskMemory'
collect2.exe: error: ld returned 1 exit status
make[1]: *** [out_cm7/CM7.elf] Error 1
***/MakefileCM7.mk:288: recipe for target 'out_cm7/CM7.elf' failed
make[1]: Leaving directory '***'
make: *** [includeMakefileCM7] Error 2
makefile:65: recipe for target 'includeMakefileCM7' failed
"make -j all_CM7" terminated with exit code 2. Build might be incomplete.
If you alreadey raised this kind of issue, it would help otherwise we will stay in whole C.
Thank you for your help!
Kind regards,
Isabelle
Solved! Go to Solution.
2020-11-14 12:16 AM
Hello,
I took sometimes to be sure we had our system working fine with extern "C" added where it is needed.
We have now all our project running with gcc for C files, g++ with cpp file.
For the file in cpp where some functions were coded initially in C, we added the extern "C".
We link everything with g++.
FreeRTOS and HAL are executing as expected.
Thank you!
Isabelle Magi
2020-10-26 11:43 AM
prvGetRegistersFromStack() is in a C source code.
It is used by stm32h7xx_it.c which is a C++ code (consider to use the cpp extension)
Does the declaration of prvGetRegistersFromStack() specify that it is a function in C, i.e. surrounded by:
#ifdef __cplusplus
extern "C" {
#endif
......
#ifdef __cplusplus
}
#endif
Dou you compile the code containing these functions and variables, and link the object file?
2020-11-14 12:16 AM
Hello,
I took sometimes to be sure we had our system working fine with extern "C" added where it is needed.
We have now all our project running with gcc for C files, g++ with cpp file.
For the file in cpp where some functions were coded initially in C, we added the extern "C".
We link everything with g++.
FreeRTOS and HAL are executing as expected.
Thank you!
Isabelle Magi