cancel
Showing results for 
Search instead for 
Did you mean: 

Linker problem on SW4STM32 - Undefined reference to HAL_I2C_MASTER_TRANSMIT

DPetr.1
Associate

Hello, I'm using stm32l152re nucleo board and I've to connect an accelerometer with I2c.

All is ok, but when I build the project the linker says "Undefined reference to HAL_I2C_MASTER_TRANSMIT". That's a function of stm32l1xx_hal_i2c.h and I can't understand why the linker gives error. I've checked all the inclusions , but it still doesn't work.

could you help me , please?

3 REPLIES 3
AvaTar
Lead

> That's a function of stm32l1xx_hal_i2c.h and I can't understand why the linker gives error

Header files are for declarations only (by convention, actually).

You need to add the respective *.c file containing the implementation to your project.

DPetr.1
Associate

The .c file is in Drivers Folder and I enabled the I2C with declaration "I2C_HandleTypeDef hi2c; ".

Maybe, can I move this file to 'src' folder ?

AvaTar
Lead

I don't know SW4STM32, and it's project organization.

But usually, you don't need to move files to add them to a project.

Organization of source files within a project would be your (the developer's) task, within the restrictions enforced by the IDE's project metaphor. Eclipse in your case.