Skip to main content
DPetr.1
Associate
October 4, 2018
Question

Linker problem on SW4STM32 - Undefined reference to HAL_I2C_MASTER_TRANSMIT

  • October 4, 2018
  • 3 replies
  • 1318 views

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?

    This topic has been closed for replies.

    3 replies

    AvaTar
    Senior III
    October 4, 2018

    > 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
    DPetr.1Author
    Associate
    October 4, 2018

    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
    Senior III
    October 4, 2018

    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.