cancel
Showing results for 
Search instead for 
Did you mean: 

Linker errors for sensor data processing functions in STM32CubeIDE + TouchGFX

Rafla
Associate III

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!

Additional Info:

  • STM32CubeIDE version: 1.17.0

  • Compiler: arm-none-eabi-gcc 12.3.1

  • Target MCU: STM32H750B-DK

  • Using C++ and TouchGFX framework

7 REPLIES 7
Nathan_Xi
Associate III

Hello @Rafla 

Maybe you can present more details.

It's hard to identify your bug with the information given.

Thanks.

MM..1
Chief III

You dont show code , but for C++ you maybe skip use right C headers...

Learn how use 

#ifdef __cplusplus
 extern "C" {
#endif
Rafla
Associate III

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.

 

 

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.

You ask no simulator and learn how thinks works. Simulator never will compile core files! Try

#ifndef SIMULATOR
Rafla
Associate III

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!

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.