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

GCC linker error - SSD1306 library

Hi,

I'm trying to make github.com/.../nrf52-spi-i2c-master-ssd1306 to compile with GCC (linux). So far I've managed to get it compiled, but linking fails:

mkdir _build
Compiling file: nrf_log_backend_serial.c
..<snip>..
Assembling file: gcc_startup_nrf52.S
Compiling file: system_nrf52.c
Compiling file: ble_nus.c
Compiling file: softdevice_handler.c
Linking target: _build/nrf52832_xxaa.out
_build/nrf52832_xxaa_ssd1306.c.o: In function `twi_master_init':
/home/aj/blumm_fw_oled/src/./ssd1306.c:65: undefined reference to `nrf_drv_twi_init'
/home/aj/blumm_fw_oled/src/./ssd1306.c:69: undefined reference to `nrf_drv_twi_enable'
_build/nrf52832_xxaa_ssd1306.c.o: In function `ssd1306_command':
/home/aj/blumm_fw_oled/src/./ssd1306.c:225: undefined reference to `spi_transfer'
/home/aj/blumm_fw_oled/src/./ssd1306.c:225: undefined reference to `spi_transfer'
/home/aj/blumm_fw_oled/src/./ssd1306.c:225: undefined reference to `spi_transfer'
/home/aj/blumm_fw_oled/src/./ssd1306.c:225: undefined reference to `spi_transfer'
/home/aj/blumm_fw_oled/src/./ssd1306.c:225: undefined reference to `spi_transfer'
_build/nrf52832_xxaa_ssd1306.c.o:/home/aj/blumm_fw_oled/src/./ssd1306.c:225: more undefined references to `spi_transfer' follow
_build/nrf52832_xxaa_ssd1306.c.o: In function `ssd1306_command':
/home/aj/blumm_fw_oled/src/./ssd1306.c:218: undefined reference to `nrf_drv_twi_tx'
/home/aj/blumm_fw_oled/src/./ssd1306.c:218: undefined reference to `nrf_drv_twi_tx'
/home/aj/blumm_fw_oled/src/./ssd1306.c:218: undefined reference to `nrf_drv_twi_tx'
/home/aj/blumm_fw_oled/src/./ssd1306.c:218: undefined reference to `nrf_drv_twi_tx'
/home/aj/blumm_fw_oled/src/./ssd1306.c:218: undefined reference to `nrf_drv_twi_tx'
_build/nrf52832_xxaa_ssd1306.c.o:/home/aj/blumm_fw_oled/src/./ssd1306.c:218: more undefined references to `nrf_drv_twi_tx' follow
_build/nrf52832_xxaa_ssd1306.c.o: In function `ssd1306_command':
/home/aj/blumm_fw_oled/src/./ssd1306.c:225: undefined reference to `spi_transfer'
/home/aj/blumm_fw_oled/src/./ssd1306.c:218: undefined reference to `nrf_drv_twi_tx'
/home/aj/blumm_fw_oled/src/./ssd1306.c:225: undefined reference to `spi_transfer'
/home/aj/blumm_fw_oled/src/./ssd1306.c:218: undefined reference to `nrf_drv_twi_tx'
/home/aj/blumm_fw_oled/src/./ssd1306.c:218: undefined reference to `nrf_drv_twi_tx'
/home/aj/blumm_fw_oled/src/./ssd1306.c:218: undefined reference to `nrf_drv_twi_tx'
/home/aj/blumm_fw_oled/src/./ssd1306.c:218: undefined reference to `nrf_drv_twi_tx'
/home/aj/blumm_fw_oled/src/./ssd1306.c:218: undefined reference to `nrf_drv_twi_tx'
_build/nrf52832_xxaa_ssd1306.c.o:/home/aj/blumm_fw_oled/src/./ssd1306.c:218: more undefined references to `nrf_drv_twi_tx' follow
_build/nrf52832_xxaa_ssd1306.c.o: In function `ssd1306_command':
/home/aj/blummences to `nrf_drv_twi_tx' follow
collect2: error: ld returned 1 exit status
make: *** [../components/toolchain/gcc/Makefile.common:156: _build/nrf52832_xxaa.out] Error 1_fw_oled/src/./ssd1306.c:225: undefined reference to `spi_transfer'
/home/aj/blumm_fw_oled/src/./ssd1306.c:225: undefined reference to `spi_transfer'
/home/aj/blumm_fw_oled/src/./ssd1306.c:225: undefined reference to `spi_transfer'
/home/aj/blumm_fw_oled/src/./ssd1306.c:225: undefined reference to `spi_transfer'
/home/aj/blumm_fw_oled/src/./ssd1306.c:225: undefined reference to `spi_transfer'
_build/nrf52832_xxaa_ssd1306.c.o:/home/aj/blumm_fw_oled/src/./ssd1306.c:225: more undefined references to `spi_transfer' follow
_build/nrf52832_xxaa_ssd1306.c.o: In function `ssd1306_command':
/home/aj/blumm_fw_oled/src/./ssd1306.c:218: undefined reference to `nrf_drv_twi_tx'
/home/aj/blumm_fw_oled/src/./ssd1306.c:218: undefined reference to `nrf_drv_twi_tx'
/home/aj/blumm_fw_oled/src/./ssd1306.c:218: undefined reference to `nrf_drv_twi_tx'
/home/aj/blumm_fw_oled/src/./ssd1306.c:218: undefined reference to `nrf_drv_twi_tx'
/home/aj/blumm_fw_oled/src/./ssd1306.c:218: undefined reference to `nrf_drv_twi_tx'
_build/nrf52832_xxaa_ssd1306.c.o:/home/aj/blumm_fw_oled/src/./ssd1306.c:218: more undefined references to `nrf_drv_twi_tx' follow
collect2: error: ld returned 1 exit status
make: *** [../components/toolchain/gcc/Makefile.common:156: _build/nrf52832_xxaa.out] Error 1

The Linker script is:

/* Linker script to configure memory regions. */

SEARCH_DIR(.)
GROUP(-lgcc -lc -lnosys)

MEMORY
{
  FLASH (rx) : ORIGIN = 0x1f000, LENGTH = 0x61000
  RAM (rwx) :  ORIGIN = 0x20002128, LENGTH = 0xded8
}

SECTIONS
{
  .fs_data :
  {
    PROVIDE(__start_fs_data = .);
    KEEP(*(.fs_data))
    PROVIDE(__stop_fs_data = .);
  } > RAM
  .pwr_mgmt_data :
  {
    PROVIDE(__start_pwr_mgmt_data = .);
    KEEP(*(.pwr_mgmt_data))
    PROVIDE(__stop_pwr_mgmt_data = .);
  } > RAM
} INSERT AFTER .data;

INCLUDE "nrf5x_common.ld"

Any suggestion on how to solve this ? Attached is the full source without the SDK. The tree structure is given below. Directories components and external that are part of SDK are not included in the attachment:

[aj@aura-arch]: ~/blumm_fw_oled>$ tree -L 2
.
├── components
│   ├── ant
│   ├── ble
│   ├── boards
│   ├── device
│   ├── drivers_ext
│   ├── drivers_nrf
│   ├── libraries
│   ├── nfc
│   ├── proprietary_rf
│   ├── sdk_validation.h
│   ├── serialization
│   ├── softdevice
│   └── toolchain
├── external
│   ├── cifra_AES128-EAX
│   ├── fatfs
│   ├── freertos
│   ├── licenses_external.txt
│   ├── micro-ecc
│   ├── nano-pb
│   ├── nfc_adafruit_library
│   ├── nrf_cc310
│   ├── protothreads
│   ├── rtx
│   ├── segger_rtt
│   └── tiny-AES128
├── README.md
└── src
    ├── binary.h
    ├── ble_app_uart_gcc_nrf52.ld
    ├── glcdfont.c
    ├── main.c
    ├── Makefile
    ├── sdk_config.h
    ├── spi_module.c
    ├── spi_module.h
    ├── ssd1306.c
    ├── ssd1306.h
    ├── uart_module.c
    └── uart_module.h

src.zip

Related