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

Linker Error Undefined reference to 'something'

I am trying to get nRF52832 working with Segger Embedded Studio. All the examples happily compile and load and run on the board.

But, I want to write my own basic hello world from scratch. So I got the most basic of all projects - blinky and tried to add UART support to it.

Basically, relevant part of my main.c file is like this

#include <stdbool.h>
#include <stdint.h>
#include "nrf.h"
#include "nrf_delay.h"
#include "boards.h"
#include "nrf_gpio.h"
#include "app_uart.h"
    ...
int main(void)  {

    uint32_t err_code;
    /* Configure board. */
//bsp_board_leds_init();
nrf_gpio_cfg_output(18);
nrf_gpio_pin_set(18);
nrf_gpio_cfg_input(13,NRF_GPIO_PIN_PULLUP);

const app_uart_comm_params_t comm_params =
  {
      8,
      6,
      5,
      7,
      APP_UART_FLOW_CONTROL_ENABLED,
      false,
      UART_BAUDRATE_BAUDRATE_Baud115200
  };

do                                                                                             \
{                                                                                              \
    app_uart_buffers_t buffers;                                                                \
    static uint8_t     rx_buf[256];                                                    \
    static uint8_t     tx_buf[256];                                                    \
                                                                                               \
    buffers.rx_buf      = rx_buf;                                                              \
    buffers.rx_buf_size = sizeof (rx_buf);                                                     \
    buffers.tx_buf      = tx_buf;                                                              \
    buffers.tx_buf_size = sizeof (tx_buf);                                                     \
    
    app_uart_init(&comm_params, &buffers, uart_error_handle, APP_IRQ_PRIORITY_LOWEST);                  \
} while (0);
...

    }

It compiles happily BUT THE LINKER FAILS!!!! THE LINKER FAILS!!!

Building 'blinky_pca10040_s132' from solution 'blinky_pca10040_s132' in configuration 'nrf52832_xxaa'
  Compiling 'main.c'
  Generating linker script 'blinky_pca10040_s132.ld'
  Linking blinky_pca10040_s132.elf
    _build/main.o: In function `uart_send_msg':
    undefined reference to `app_uart_put'
    _build/main.o: In function `main':
    undefined reference to `app_uart_init'
    undefined reference to `app_uart_get'
    undefined reference to `app_uart_put'
Build failed

What do I need to do?

URGENT!!! HELP!!!

Also, can someone just write a quick blog post on how to start our own project in Segger Embedded Studio, what settings need to be configured for include files and linker files so that some guy can atleast start doing their project.

Related