2025-05-15 8:39 AM
Hello everyone,
I’m developing an STM32H750 application using STM32CubeIDE and TouchGFX, and I’m trying to integrate a sensor using I2C.
I implemented a sensor driver and added the corresponding source files, but I’m running into linker errors like:
undefined reference to `Sensor_Calc()'
I made sure the source files are included in the build and headers properly referenced, but the errors persist.
If anyone has working examples, suggestions, I’d be grateful.
Thanks for your help!
STM32CubeIDE version: 1.17.0
Compiler: arm-none-eabi-gcc 12.3.1
Target MCU: STM32H750B-DK
Using C++ and TouchGFX framework
2025-05-15 6:57 PM
Hello @Rafla
Maybe you can present more details.
It's hard to identify your bug with the information given.
Thanks.
2025-05-15 10:14 PM
You dont show code , but for C++ you maybe skip use right C headers...
Learn how use
#ifdef __cplusplus
extern "C" {
#endif
2025-05-17 3:35 PM
The code compiles fine on the real target, but when I try to build the TouchGFX Simulator, I get the following error repeatedly:
fatal error: i2c_data.h: No such file or directory
The i2c_data.h file is present in my project under Core/Inc.
It seems the simulator build does not include the folder containing i2c_data.h in its include paths.
2025-05-17 3:39 PM
The code compiles fine on the real target, but when I try to build the TouchGFX Simulator, I get the following error repeatedly:
fatal error: i2c_data.h: No such file or directory
The i2c_data.h file is present in my project under Core/Inc.
It seems the simulator build does not include the folder containing i2c_data.h in its include paths.
2025-05-17 11:39 PM
You ask no simulator and learn how thinks works. Simulator never will compile core files! Try
#ifndef SIMULATOR
2025-05-18 3:22 PM
The simulation mode works perfectly when I use Run Simulator, and everything builds and runs without errors.
However, when I try "Program and Run Target", the compilation succeeds but I get linker errors complaining about undefined references to functions that I’ve implemented in a .c file located in Core/Src.
This .c file is used in main.c, and I’ve already included the corresponding .h file.
I suspect the file is not being compiled or linked during the target build.
I tried to add the file manually in app.mk, but I couldn’t find where to do it correctly for the target (not the simulator).
How can I include a custom .c file located in Core/Src so it gets compiled and linked correctly when building?
Thanks in advance for your help!
2025-05-19 9:05 AM
TGFX isnt prepared to use this way with custom code. Only preset examples use run on target button, and here too dont work add new files only edit exist. Customize this is possible , but waste of time, normal steps is open IDE here is edit/add all and any core files , here exist green button to build and load to target.