Getting Linker Errors "undefined references to..."

I'm just starting to make a project using SDK 17.1, which is loosely based on a working, mature project based on SDK 15.2 and I'm hitting a bunch of issues. My path here is to copy an example (in my case beacon) and then strip everything out and add stuff back in slowly as needed.

Right now I'm just trying to nrfx_rtc, nrfx_spim, and printf via app_uart working to read in some sensor data and print to a terminal program. Everything compiles all the way to linking the .elf and I get:

  • undefined reference to 'app_uart_init'
  • undefined reference to 'nrfx_rtc_init'
  • undefined reference to 'nrfx_spim_xfer'

app_uart doesn't seem to have any entries in sdk_config.h any more but the nrfx_rtc and nrtx_spim are both enabled so I'm not at all sure what's going on.

Any thoughts or things I should be looking at? This SDK has always confused the bejesus out of me so I don't have any clue where it's all going wrong.

Adam

Parents Reply Children
  • It's definitely something related to my sdk_config.h not being looked at. Why the %)(* does this even exist or need to be so complicated? Why can't I just initialize a driver in my code and be done? Why can't I just copy and paste the defines from the sdk_config into my project?

    Is there a way to just remove the need for sdk_config.h? I'm just trying to get a simple project with SPIM working and it's taken me DAYS. It would have taken hours with other vendor's sdk.

    Also, there is another sdk_config.h in config/nrf52840/config that's not even the same sdk_config.h that's in the example! How is this such a disaster?

  • Hello,

    The "Migration guide for nrfx drivers" section of SDK documentation gives some background as to why things are the way they are with regards to the nrfx drivers. The problem you are encountering here is caused by the apply_old_config.h header which will override NRFX_* entries based on what the corresponding legacy configurations are set to. For instance, if you have SPI_ENABLED set to '0', then apply_old_config.h will automatically override your NRFX_SPIM_ENABLED setting and set it to '0'.

    The easiest solution to get around this is to configure your project only using the legacy nrf_drv_* configurations and ignore the NRFX_* entries. The other option is to remove the nrf_drv_* entries from your sdk_config file, but it is a bit of a tedious task to go through the sdk_config file and remove entries assuming you care about keeping the configuration wizard format (Configuration Wizard Annotations , SDK configuration header file).

    Adam Gerken said:
    Is there a way to just remove the need for sdk_config.h?

    Yes. You can make your own version of the sdk_config that only includes configuration settings relevant to your project. You can use other sdk examples to figure out what settings to include. You can for instance use the ble_app_uart example to find the settings needed for using the app_uart library,  the /peripheral/spi example for SPIM, and so on.

    Best regards,

    Vidar

Related