2022-02-06 12:52 PM
Something weird is going on with my STM32Cube project building. I have a fresh project created from the template for the STM32H745I-DISCO. In the Core/Inc folder I created a foo.h header file containing a method. In the Core/Src folder, I wrote the implementation of that method in foo.cpp. I added the header and source files to the build path, but when I try to call the method in foo.h in main, I get "undefined reference to method". In the debug files, the foo.cpp gets compiled to a .o file, leading me to think it is a linker issue.
2022-02-06 01:53 PM
>>leading me to think it is a linker issue.
Yeah, most times it will be apparent whether the compiler or linker is complaining.
The actual build log, and specific error details might help gain some perspective here.
If you include a .H from a .C file it might not get the name-mangling done, but you indicate you're doing a .CPP file.
Perhaps you can inspect the object with objcopy or fromelf type tools to get symbols and disassemblies.
2022-02-07 12:22 AM
@Community member "The actual build log, and specific error details might help gain some perspective here"
The "actual build log" will be found in the 'Console' window:
"If you include a .H from a .C file it might not get the name-mangling done"
+1
Check that it is being compiled as C++ - not C
2022-02-07 06:15 AM
You "call the method in foo.h in main". Main is C or C++ ?
2022-02-07 04:30 PM
Main is a C file. I switched it to a .CPP and it compiles now.
2022-02-08 02:18 AM