This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

"Undefined Reference" on the linker level

Hi. I am a beginner with nrf52832. Trying to get Bluetooth and UART and a I2C peripheral working at the same time. I had a working version of the I2C peripheral and UART working together and tried to merge Bluetooth in, referencing the ble_app_uart example provided in nRF5_SDK_12.3.0. Currently when I try to do make flash I do not get any compiling errors, but I am getting linker errors that say that I have "undefined reference":

Linking target: _build/nrf52832_xxaa.out
_build/nrf52832_xxaa_twi.c.o: In function `twi_master_init':
/home/yilunsheng/src/accelerometer, SDK12.3, app_uart_merge/./twi.c:43: undefined reference to `nrf_drv_twi_init'
/home/yilunsheng/src/accelerometer, SDK12.3, app_uart_merge/./twi.c:46: undefined reference to `nrf_drv_twi_enable'
_build/nrf52832_xxaa_lis3dh.c.o: In function `lis3dh_read_data':
/home/yilunsheng/src/accelerometer, SDK12.3, app_uart_merge/./lis3dh.c:171: undefined reference to `nrf_drv_twi_tx'
/home/yilunsheng/src/accelerometer, SDK12.3, app_uart_merge/./lis3dh.c:180: undefined reference to `nrf_drv_twi_rx'
_build/nrf52832_xxaa_lis3dh.c.o: In function `lis3dh_init':
/home/yilunsheng/src/accelerometer, SDK12.3, app_uart_merge/./lis3dh.c:232: undefined reference to `nrf_drv_twi_tx'
collect2: error: ld returned 1 exit status
../nRF5_SDK_12.3.0/components/toolchain/gcc/Makefile.common:153: recipe for target '_build/nrf52832_xxaa.out' failed
make: *** [_build/nrf52832_xxaa.out] Error 1

Very confused about where the problem is.

Parents
  • You have not included the source file that implements the functions in your project

    This is a standard 'C' issue - nothing specifically to do with Nordic.

    However, in this case, I would have thought you would have got compile errors?

    ou have not enabled the module in your project's sdk_config.h file.

    This one is specific to the way Nordic configure their SDKs.

    As   said, this one is a frequent cause of confusion - so maybe there's a clue for Nordic there, that it needs to be better explained...?

  • However, in this case, I would have thought you would have got compile errors?

    As long as the header file where the function is declared is included, you will not get compilation error. If header file is included but source file is not included in project, you will get this linker error.

    this one is a frequent cause of confusion - so maybe there's a clue for Nordic there, that it needs to be better explained...?

    I think it is explained well in the documentation:

    "Every module in SDK contains at least one configuration option that enables this module. If the module is disabled, then even if source code is added to the project, it is not compiled because the module implementation is conditionally included."

    I will say that is should be expected of customers to read through the Getting Started section of the SDK documentation to get familiar with the SDK before starting to develop applications.

Reply
  • However, in this case, I would have thought you would have got compile errors?

    As long as the header file where the function is declared is included, you will not get compilation error. If header file is included but source file is not included in project, you will get this linker error.

    this one is a frequent cause of confusion - so maybe there's a clue for Nordic there, that it needs to be better explained...?

    I think it is explained well in the documentation:

    "Every module in SDK contains at least one configuration option that enables this module. If the module is disabled, then even if source code is added to the project, it is not compiled because the module implementation is conditionally included."

    I will say that is should be expected of customers to read through the Getting Started section of the SDK documentation to get familiar with the SDK before starting to develop applications.

Children
Related