cancel
Showing results for 
Search instead for 
Did you mean: 

Issue to compile C and C++ with FreeRTOS, functions not recognized on stm32h7xx_it.c

IMAGI.1
Associate

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

1 ACCEPTED SOLUTION

Accepted Solutions
IMAGI.1
Associate

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

View solution in original post

2 REPLIES 2
Nikita91
Lead II

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?

IMAGI.1
Associate

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