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 Reply Children
  • and why does the forum quote feature keep going wrong like that - ie, the quoted text is outside the quote marker!

  • I agree that dependencies could have been documented better, but this is more related to the modules themselves, rather than the sdk_config.h file. You still needs to include the source files of the dependent modules.

    It might take some iterations to add all sub-modules that a module depends on, but the compiler will give you hints to what needs to be included/enabled.

  • this is more related to the modules themselves, rather than the sdk_config.h file

    Indeed.

    But see my linked thread - I didn't see anywhere that told me what files I needed to include!

    the compiler will give you hints to what needs to be included/enabled

    Indeed - but we're back to development by reverse-engineering again.

    We shouldn't have to discover this stuff by trial & error - it should be clearly documented up-front.

  • Like I said, I agree that this is not well documented. We have an internal task requesting more documentation on library dependency documentation.

  • That's good to hear!

    So, for input to that task, let's just look at the TWI driver as an example:

    http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v15.2.0/group__nrfx__twi.html

    I don't see anything there at all which tells which files need to be added to a Project.

    There is a link to "TWI peripheral driver configuration"

    This does list NRFX_TWI_ENABLED - and says  "set to 1 to activate"

    But it's not really clear where that setting has to be made.

    There's a note saying, "This is an NRF_CONFIG macro" - but what does that mean? 

    I guess it's supposed to tell us that it's in sdk_config.h - is it?

    It would be clearer if that were explicitly stated - with a link to the sdk_config.h documentation.