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

Linker Error :: while upgrading the sdk version to 13

HI All,

I am trying to upgrade sdk v11 to sdk v13 in my  project and after compilation i am facing Linker Error as mentioned below.

binaries/app/SmartTag2/dfuFlash.c.o:/home/dcpl/Videos/Tack_Test_31_May/ToolChainSetup/coolR/build/linux/../../components/nordic/softdevice/s132/headers/ble_gap.h:2157: multiple definition of `m_fs'
binaries/app/SmartTag2/fds.c.o:(.fs_data+0x0): first defined here
binaries/app/SmartTag2/bleDrv.c.o:(.sdh_ble_observers1+0x8): undefined reference to `ble_db_discovery_on_ble_evt'
binaries/app/SmartTag2/bleDrv.c.o: In function `client_init':
/home/dcpl/Videos/Tack_Test_31_May/ToolChainSetup/coolR/build/linux/../../source/peripherals/bluetooth/bleDrv.c:2458: undefined reference to `ble_db_discovery_init'
binaries/app/SmartTag2/bleDrv.c.o: In function `on_ble_gap_evt_connected':
/home/dcpl/Videos/Tack_Test_31_May/ToolChainSetup/coolR/build/linux/../../source/peripherals/bluetooth/bleDrv.c:2542: undefined reference to `ble_db_discovery_start'
binaries/app/SmartTag2/amtc.c.o: In function `nrf_ble_amtc_init':
/home/dcpl/Videos/Tack_Test_31_May/ToolChainSetup/coolR/build/linux/../../source/peripherals/bluetooth/amtc.c:289: undefined reference to `ble_db_discovery_evt_register'
binaries/app/SmartTag2/ble_dfu.c.o: In function `ble_dfu_buttonless_bootloader_start_finalize':
/home/dcpl/Videos/Tack_Test_31_May/ToolChainSetup/coolR/build/linux/../../components/nordic/ble/ble_services/ble_dfu/ble_dfu.c:295: undefined reference to `nrf_pwr_mgmt_shutdown'
collect2: error: ld returned 1 exit status
../../components/nordic/toolchain/gcc/Makefile.common:292: recipe for target 'binaries/app/SmartTag2.out' failed
make: *** [binaries/app/SmartTag2.out] Error 1

also i am attaching my linker script.

please help me to resolved this error.

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

MEMORY
{
	/* Flash partitions */
/*	MBR				(rx)	:   ORIGIN = 0x00000000, LENGTH = 0x01000		/* Master Boot Record, size = 4KB  */
/*	SOFTDEVICE		(rx)	:   ORIGIN = 0x00001000, LENGTH = 0x1E000		/* Softdevice, size = 120KB */
	APPLICATION		(rx)	:	ORIGIN = 0x0001F000, LENGTH = 0x45000		/* Application, size = 340KB */
/*	BOOTLOADER		(rx)	:   ORIGIN = 0x00074000, LENGTH = 0x06000		/* Bootloader, size = 24KB */
/*	MBR_SETTING		(rw)	:   ORIGIN = 0x0007A000, LENGTH = 0x01000		/* MBR setting, size = 4KB */
	BL_SETTING		(rw)	:   ORIGIN = 0x0007B000, LENGTH = 0x01000		/* BL setting, size = 4KB */
	NVCONFIG		(rw)	:	ORIGIN = 0x0007C000, LENGTH = 0x04000		/* NVconfig, size = 16KB */
	

	/* RAM partitions */
/*	MBR_SD			(rw)	:	ORIGIN = 0x20000000, LENGTH = 0x2128		/* */
	RAM 			(rwx)	:	ORIGIN = 0x20002128, LENGTH = 0xAED8		/* */
	DM_RAM_BUFFER	(rwx)	:	ORIGIN = 0x2000D000, LENGTH = 0x1000		/* */	
	CONFIG 			(rwx) 	:	ORIGIN = 0x2000E000, LENGTH = 0x2000        /* */
}
/*
SECTIONS
{
	.config :
	{
		PROVIDE(__start_config = .);
	    KEEP(*(.config))
    	PROVIDE(__stop_config = .);
	} > CONFIG
}
*/
SECTIONS
{
  .config(NOLOAD) :
  {

  } > CONFIG
}

SECTIONS
{
  .dmRamBuffer(NOLOAD) :
  {

  } > DM_RAM_BUFFER
}

SECTIONS
{
   /* Place the bootloader settings page in flash. */
  .bootloaderSettings(NOLOAD) :
  {
	
  } > BL_SETTING
  .cli_sorted_cmd_ptrs :
  {
    PROVIDE(__start_cli_sorted_cmd_ptrs = .);
    KEEP(*(.cli_sorted_cmd_ptrs))
    PROVIDE(__stop_cli_sorted_cmd_ptrs = .);
  } > RAM
  .log_dynamic_data :
  {
    PROVIDE(__start_log_dynamic_data = .);
    KEEP(*(SORT(.log_dynamic_data*)))
    PROVIDE(__stop_log_dynamic_data = .);
  } > RAM
  .fs_data :
  {
    PROVIDE(__start_fs_data = .);
    KEEP(*(.fs_data))
    PROVIDE(__stop_fs_data = .);
  } > RAM
} INSERT AFTER .data;

SECTIONS
{
  .mem_section_dummy_rom :
  {
  }
  .sdh_soc_observers :
  {
    PROVIDE(__start_sdh_soc_observers = .);
    KEEP(*(SORT(.sdh_soc_observers*)))
    PROVIDE(__stop_sdh_soc_observers = .);
  } > APPLICATION
  .pwr_mgmt_data :
  {
    PROVIDE(__start_pwr_mgmt_data = .);
    KEEP(*(SORT(.pwr_mgmt_data*)))
    PROVIDE(__stop_pwr_mgmt_data = .);
  } > APPLICATION
  .sdh_ble_observers :
  {
    PROVIDE(__start_sdh_ble_observers = .);
    KEEP(*(SORT(.sdh_ble_observers*)))
    PROVIDE(__stop_sdh_ble_observers = .);
  } > APPLICATION
    .cli_command :
  {
    PROVIDE(__start_cli_command = .);
    KEEP(*(.cli_command))
    PROVIDE(__stop_cli_command = .);
  } > APPLICATION
  .log_const_data :
  {
    PROVIDE(__start_log_const_data = .);
    KEEP(*(SORT(.log_const_data*)))
    PROVIDE(__stop_log_const_data = .);
  } > APPLICATION
  .sdh_req_observers :
  {
    PROVIDE(__start_sdh_req_observers = .);
    KEEP(*(SORT(.sdh_req_observers*)))
    PROVIDE(__stop_sdh_req_observers = .);
  } > APPLICATION
  .sdh_state_observers :
  {
    PROVIDE(__start_sdh_state_observers = .);
    KEEP(*(SORT(.sdh_state_observers*)))
    PROVIDE(__stop_sdh_state_observers = .);
  } > APPLICATION
  .sdh_stack_observers :
  {
    PROVIDE(__start_sdh_stack_observers = .);
    KEEP(*(SORT(.sdh_stack_observers*)))
    PROVIDE(__stop_sdh_stack_observers = .);
  } > APPLICATION


} INSERT AFTER .text

INCLUDE "nrf52_common.ld"

Parents Reply Children
  • Sounds good.

    There are basically two types of linker errors in your log, as we have already discussed:

    • the "multiple definition" error, and
    • the "undefined reference".

    I have made some suggestions for both errors. But to make it clearer for the "undefined reference", you should check a few things

    1. Ensure that you actually build the .c file which has the reference which is undefined.
    2. If you include the file and it still does not work, then probably it is removed by the preprocessor.

    I can elaborate on the second point, as the sdk_config.h concept can be a bit confusing when you are not used to it. Try looking at the file, and you should will typically see a #ifdef or #if NRF_MODULE_ENABLED(...). For the "undefined reference to `ble_db_discovery_on_ble_evt'" error, you can see that in the top of ble_db_discovery.c there is a #if NRF_MODULE_ENABLED(BLE_DB_DISCOVERY). This means that everything until the matching #endif will be removed by the preprocessor if not BLE_DB_DISCOVERY_ENABLED is set to 1 in the projects sdk_config.h. So, the fix is probably to set BLE_DB_DISCOVERY_ENABLED in your projects sdk_config.h.

    I am sure you will root out the errors once you start handling them one by one. Good luck!

  • Hi,

    i am only getting this error, rest of the error's will resolved new.

    just conform me what is the next steps.

    binaries/app/SmartTag2/dfuFlash.c.o:(.fs_data+0x0): multiple definition of `m_fs'
    binaries/app/SmartTag2/fds.c.o:(.fs_data+0x0): first defined here
    collect2: error: ld returned 1 exit status

  • Apparently, a global m_fs is defined both in your dfuFlash.c and in fds.c. Renaming whatever you have in dfuFlash.c that is called m_fs should fix the issue. If you intend this to be the same "object" on the other hand, then you should declare one of them as extern.

  • Thanks, i am getting your point. i can resolved all errors in my program. thanks

Related