Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs

Why am i geting an undefined reference linking error in C

I'm doing some experiments with the nRF52840 and SEGGER Embedded Studio. I'm quite new to C but managed to get desired results using and changing the examples. I'm now trying to port the uart example to the two way ranging example to send the results to an external device but keep running into the following error:

I pinpointed the error (I think at least) to the following piece of code in a file named app_uart.h the problematic functions gets called in the second last line of the following code block:

uint32_t app_uart_init(const app_uart_comm_params_t * p_comm_params,
                       app_uart_buffers_t *           p_buffers,
                       app_uart_event_handler_t       error_handler,
                       app_irq_priority_t             irq_priority);

// TODO no reference to app_uart_init()

#define APP_UART_FIFO_INIT(P_COMM_PARAMS, RX_BUF_SIZE, TX_BUF_SIZE, EVT_HANDLER, IRQ_PRIO, ERR_CODE) \
    do                                                                                             \
    {                                                                                              \
        app_uart_buffers_t buffers;                                                                \
        static uint8_t     rx_buf[RX_BUF_SIZE];                                                    \
        static uint8_t     tx_buf[TX_BUF_SIZE];                                                    \
                                                                                                   \
        buffers.rx_buf      = rx_buf;                                                              \
        buffers.rx_buf_size = sizeof (rx_buf);                                                     \
        buffers.tx_buf      = tx_buf;                                                              \
        buffers.tx_buf_size = sizeof (tx_buf);                                                     \
        ERR_CODE = app_uart_init(P_COMM_PARAMS, &buffers, EVT_HANDLER, IRQ_PRIO);                  \
    } while (0)

The error is, according to SEGGER Embedded Studio, in my ds_twr_responder.c file pointing to the function call

 APP_UART_FIFO_INIT(&com_params, UART_RX_BUFF_SIZE, UART_TX_BUFF_SIZE, uart_err_handle, APP_IRQ_PRIORITY_LOWEST, err_code);

going to the declaration of the function brigs us to app_uart.h. this file is in de same directory as ds_twr_responder.c along with app_uart.c (in which the function is defined)

I don't really kno where to look as i'm not sure why this error could possibly pop up. Is there some direction i should be looking in?

Parents
  • Hi

    It seems you haven't added the necessary header files to this new project you're working on. Adding header files are done by adding the folder path in the user include directories. RIght click the project in SEGGER, select settings, set the build configuration to Common, go to Preprocessor and open User Include DIrectories, and add the folder that app_uart.h is located in to your project. You'll likely have more undefined reference errors like this as well, and you will have to add the folder paths to those header files to your user include directories as well.

    Best regards,

    Simon

    PS: The Holiday season is upon us, which will leave the Nordic support team understaffed until January 3rd, 2022. This means that delayed replies will occur during this time. Sorry about the inconvenience and happy Holidays!

Reply
  • Hi

    It seems you haven't added the necessary header files to this new project you're working on. Adding header files are done by adding the folder path in the user include directories. RIght click the project in SEGGER, select settings, set the build configuration to Common, go to Preprocessor and open User Include DIrectories, and add the folder that app_uart.h is located in to your project. You'll likely have more undefined reference errors like this as well, and you will have to add the folder paths to those header files to your user include directories as well.

    Best regards,

    Simon

    PS: The Holiday season is upon us, which will leave the Nordic support team understaffed until January 3rd, 2022. This means that delayed replies will occur during this time. Sorry about the inconvenience and happy Holidays!

Children
No Data
Related