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

SES linker error

Hello,

I've modified(added custom libraries) an existing example project from the SDK(v 15.3), and I'm trying to build and flash it.

The project compiles fine, but throws a bunch of linker errors as shown below:

Can someone help with where to begin with resolving these errors? I'm new to firmware development.

Parents Reply Children
  • As said earlier, it looks like you may have variable definitions in your headers.

    http://c-faq.com/decl/decldef.html

  • Back on this again,

    I inspected the header files, I really could not see variable definitions, I only found variable declarations.
    Any other source of the'multiple definition' linker error?

    I also tried enabling 'allow multiple definition' in the project Linker options. The project builds successfully now, but will this approach work?

  • Any other source of the'multiple definition' linker error?

    The error messages tell you where all of the multiple definitions are being found.

    Post an up-to-date build log.

    (post it as for source code, but omit step 3).

    will this approach work

    You should not have multiple definitions - so this approach would only be hiding what really are errors in your code.

    So, even if it did appear to work under certain circumstances, it would be on very shaky foundations!

  • This is the build log:

    Building ‘ble_bse_pca10056_s140’ from solution ‘ble_bse_pca10056_s140’ in configuration ‘Debug’
      'Output/ble_bse_pca10056_s140 Debug/Obj/thumb_crt0.o' is up to date
      'Output/ble_bse_pca10056_s140 Debug/Obj/app_button.o' is up to date
      'Output/ble_bse_pca10056_s140 Debug/Obj/app_error.o' is up to date
      'Output/ble_bse_pca10056_s140 Debug/Obj/app_error_weak.o' is up to date
      'Output/ble_bse_pca10056_s140 Debug/Obj/app_scheduler.o' is up to date
      'Output/ble_bse_pca10056_s140 Debug/Obj/app_timer.o' is up to date
      'Output/ble_bse_pca10056_s140 Debug/Obj/app_util_platform.o' is up to date
      'Output/ble_bse_pca10056_s140 Debug/Obj/crc16.o' is up to date
      'Output/ble_bse_pca10056_s140 Debug/Obj/fds.o' is up to date
      'Output/ble_bse_pca10056_s140 Debug/Obj/hardfault_implementation.o' is up to date
      'Output/ble_bse_pca10056_s140 Debug/Obj/nrf_assert.o' is up to date
      'Output/ble_bse_pca10056_s140 Debug/Obj/nrf_atfifo.o' is up to date
      'Output/ble_bse_pca10056_s140 Debug/Obj/nrf_balloc.o' is up to date
      'Output/ble_bse_pca10056_s140 Debug/Obj/nrf_fprintf.o' is up to date
      'Output/ble_bse_pca10056_s140 Debug/Obj/nrf_fprintf_format.o' is up to date
      'Output/ble_bse_pca10056_s140 Debug/Obj/nrf_fstorage.o' is up to date
      'Output/ble_bse_pca10056_s140 Debug/Obj/nrf_fstorage_sd.o' is up to date
      'Output/ble_bse_pca10056_s140 Debug/Obj/nrf_memobj.o' is up to date
      'Output/ble_bse_pca10056_s140 Debug/Obj/nrf_pwr_mgmt.o' is up to date
      'Output/ble_bse_pca10056_s140 Debug/Obj/nrf_section_iter.o' is up to date
      'Output/ble_bse_pca10056_s140 Debug/Obj/nrf_strerror.o' is up to date
      'Output/ble_bse_pca10056_s140 Debug/Obj/sdk_mapped_flags.o' is up to date
      'Output/ble_bse_pca10056_s140 Debug/Obj/sensorsim.o' is up to date
      'Output/ble_bse_pca10056_s140 Debug/Obj/nrf_queue.o' is up to date
      'Output/ble_bse_pca10056_s140 Debug/Obj/nrf_serial.o' is up to date
      'Output/ble_bse_pca10056_s140 Debug/Obj/nrf_block_dev_sdc.o' is up to date
      'Output/ble_bse_pca10056_s140 Debug/Obj/app_sdcard.o' is up to date
      'Output/ble_bse_pca10056_s140 Debug/Obj/nrf_drv_spi.o' is up to date
      'Output/ble_bse_pca10056_s140 Debug/Obj/boards.o' is up to date
      'Output/ble_bse_pca10056_s140 Debug/Obj/nrf_drv_clock.o' is up to date
      'Output/ble_bse_pca10056_s140 Debug/Obj/nrf_drv_common.o' is up to date
      'Output/ble_bse_pca10056_s140 Debug/Obj/nrf_drv_gpiote.o' is up to date
      'Output/ble_bse_pca10056_s140 Debug/Obj/nrf_drv_uart.o' is up to date
      'Output/ble_bse_pca10056_s140 Debug/Obj/bsp.o' is up to date
      'Output/ble_bse_pca10056_s140 Debug/Obj/bsp_btn_ble.o' is up to date
      'Output/ble_bse_pca10056_s140 Debug/Obj/bsp_nfc.o' is up to date
      'Output/ble_bse_pca10056_s140 Debug/Obj/main.o' is up to date
      'Output/ble_bse_pca10056_s140 Debug/Obj/SEGGER_RTT.o' is up to date
      'Output/ble_bse_pca10056_s140 Debug/Obj/SEGGER_RTT_Syscalls_SES.o' is up to date
      'Output/ble_bse_pca10056_s140 Debug/Obj/SEGGER_RTT_printf.o' is up to date
      'Output/ble_bse_pca10056_s140 Debug/Obj/ble_advdata.o' is up to date
      'Output/ble_bse_pca10056_s140 Debug/Obj/ble_advertising.o' is up to date
      'Output/ble_bse_pca10056_s140 Debug/Obj/ble_conn_params.o' is up to date
      'Output/ble_bse_pca10056_s140 Debug/Obj/ble_conn_state.o' is up to date
      'Output/ble_bse_pca10056_s140 Debug/Obj/ble_srv_common.o' is up to date
      'Output/ble_bse_pca10056_s140 Debug/Obj/gatt_cache_manager.o' is up to date
      'Output/ble_bse_pca10056_s140 Debug/Obj/gatts_cache_manager.o' is up to date
      'Output/ble_bse_pca10056_s140 Debug/Obj/id_manager.o' is up to date
      'Output/ble_bse_pca10056_s140 Debug/Obj/nrf_ble_gatt.o' is up to date
      'Output/ble_bse_pca10056_s140 Debug/Obj/peer_data_storage.o' is up to date
      'Output/ble_bse_pca10056_s140 Debug/Obj/peer_database.o' is up to date
      'Output/ble_bse_pca10056_s140 Debug/Obj/peer_id.o' is up to date
      'Output/ble_bse_pca10056_s140 Debug/Obj/peer_manager.o' is up to date
      'Output/ble_bse_pca10056_s140 Debug/Obj/pm_buffer.o' is up to date
      'Output/ble_bse_pca10056_s140 Debug/Obj/pm_mutex.o' is up to date
      'Output/ble_bse_pca10056_s140 Debug/Obj/security_dispatcher.o' is up to date
      'Output/ble_bse_pca10056_s140 Debug/Obj/security_manager.o' is up to date
      'Output/ble_bse_pca10056_s140 Debug/Obj/nrf_ble_qwr.o' is up to date
      'Output/ble_bse_pca10056_s140 Debug/Obj/ses_nRF_Startup.o' is up to date
      'Output/ble_bse_pca10056_s140 Debug/Obj/ses_nrf52840_Vectors.o' is up to date
      'Output/ble_bse_pca10056_s140 Debug/Obj/system_nrf52840.o' is up to date
      'Output/ble_bse_pca10056_s140 Debug/Obj/nrf_sdh.o' is up to date
      'Output/ble_bse_pca10056_s140 Debug/Obj/nrf_sdh_ble.o' is up to date
      'Output/ble_bse_pca10056_s140 Debug/Obj/nrf_sdh_soc.o' is up to date
      'Output/ble_bse_pca10056_s140 Debug/Obj/ble_ipn_monitor_service.o' is up to date
      'Output/ble_bse_pca10056_s140 Debug/Obj/char_enc_dec.o' is up to date
      'Output/ble_bse_pca10056_s140 Debug/Obj/ipn.o' is up to date
      'Output/ble_bse_pca10056_s140 Debug/Obj/ipnmonitor.o' is up to date
      'Output/ble_bse_pca10056_s140 Debug/Obj/logic.o' is up to date
      'Output/ble_bse_pca10056_s140 Debug/Obj/rs485.o' is up to date
      'Output/ble_bse_pca10056_s140 Debug/Obj/sdcard.o' is up to date
      'Output/ble_bse_pca10056_s140 Debug/Obj/sdclog.o' is up to date
      'Output/ble_bse_pca10056_s140 Debug/Obj/service_if.o' is up to date
      'Output/ble_bse_pca10056_s140 Debug/Obj/ff.o' is up to date
      'Output/ble_bse_pca10056_s140 Debug/Obj/diskio_blkdev.o' is up to date
      'Output/ble_bse_pca10056_s140 Debug/Obj/unicode.o' is up to date
      Allow Multiple Symbol Definition property has changed.
      Linking ble_bse_pca10056_s140.elf
        Output/ble_bse_pca10056_s140 Debug/Obj/ipn.o:C:\nRF\Project\ble_bse/data.h:131: multiple definition of `ipn_messages_timeout'; Output/ble_bse_pca10056_s140 Debug/Obj/main.o:C:\nRF\Project\ble_bse/data.h:131: first defined here
        Output/ble_bse_pca10056_s140 Debug/Obj/ipn.o:C:\nRF\Project\ble_bse/data.h:132: multiple definition of `pro_remote_timeout'; Output/ble_bse_pca10056_s140 Debug/Obj/main.o:C:\nRF\Project\ble_bse/data.h:132: first defined here
        Output/ble_bse_pca10056_s140 Debug/Obj/ipn.o:C:\nRF\Project\ble_bse/data.h:133: multiple definition of `ucm_timeout'; Output/ble_bse_pca10056_s140 Debug/Obj/main.o:C:\nRF\Project\ble_bse/data.h:133: first defined here
        Output/ble_bse_pca10056_s140 Debug/Obj/ipn.o:C:\nRF\Project\ble_bse/ipn.h:238: multiple definition of `ipn_state'; Output/ble_bse_pca10056_s140 Debug/Obj/main.o:C:\nRF\Project\ble_bse/ipn.h:238: first defined here
        Output/ble_bse_pca10056_s140 Debug/Obj/logic.o:C:\nRF\Project\ble_bse/data.h:131: multiple definition of `ipn_messages_timeout'; Output/ble_bse_pca10056_s140 Debug/Obj/main.o:C:\nRF\Project\ble_bse/data.h:131: first defined here
        Output/ble_bse_pca10056_s140 Debug/Obj/logic.o:C:\nRF\Project\ble_bse/data.h:132: multiple definition of `pro_remote_timeout'; Output/ble_bse_pca10056_s140 Debug/Obj/main.o:C:\nRF\Project\ble_bse/data.h:132: first defined here
        Output/ble_bse_pca10056_s140 Debug/Obj/logic.o:C:\nRF\Project\ble_bse/data.h:133: multiple definition of `ucm_timeout'; Output/ble_bse_pca10056_s140 Debug/Obj/main.o:C:\nRF\Project\ble_bse/data.h:133: first defined here
        Output/ble_bse_pca10056_s140 Debug/Obj/logic.o:C:\nRF\Project\ble_bse/ipn.h:238: multiple definition of `ipn_state'; Output/ble_bse_pca10056_s140 Debug/Obj/main.o:C:\nRF\Project\ble_bse/ipn.h:238: first defined here
        Output/ble_bse_pca10056_s140 Debug/Obj/logic.o:C:\nRF\Project\ble_bse/sdcard.h:39: multiple definition of `sdc_card_inserted'; Output/ble_bse_pca10056_s140 Debug/Obj/main.o:C:\nRF\Project\ble_bse/sdcard.h:39: first defined here
        Output/ble_bse_pca10056_s140 Debug/Obj/logic.o:C:\nRF\Project\ble_bse/sdcard.h:40: multiple definition of `sdc_status'; Output/ble_bse_pca10056_s140 Debug/Obj/main.o:C:\nRF\Project\ble_bse/sdcard.h:40: first defined here
        Output/ble_bse_pca10056_s140 Debug/Obj/logic.o:C:\nRF\Project\ble_bse/sdcard.h:41: multiple definition of `sdc_msg'; Output/ble_bse_pca10056_s140 Debug/Obj/main.o:C:\nRF\Project\ble_bse/sdcard.h:41: first defined here
        Output/ble_bse_pca10056_s140 Debug/Obj/logic.o:C:\nRF\Project\ble_bse/sdclog.h:18: multiple definition of `one_min_ctr'; Output/ble_bse_pca10056_s140 Debug/Obj/main.o:C:\nRF\Project\ble_bse/sdclog.h:18: first defined here
        Output/ble_bse_pca10056_s140 Debug/Obj/logic.o:C:\nRF\Project\ble_bse/sdclog.h:19: multiple definition of `six_min_ctr'; Output/ble_bse_pca10056_s140 Debug/Obj/main.o:C:\nRF\Project\ble_bse/sdclog.h:19: first defined here
        Output/ble_bse_pca10056_s140 Debug/Obj/logic.o:C:\nRF\Project\ble_bse/sdclog.h:20: multiple definition of `logging_period'; Output/ble_bse_pca10056_s140 Debug/Obj/main.o:C:\nRF\Project\ble_bse/sdclog.h:20: first defined here
        Output/ble_bse_pca10056_s140 Debug/Obj/logic.o:C:\nRF\Project\ble_bse/sdclog.h:21: multiple definition of `log_period_ctr'; Output/ble_bse_pca10056_s140 Debug/Obj/main.o:C:\nRF\Project\ble_bse/sdclog.h:21: first defined here
        Output/ble_bse_pca10056_s140 Debug/Obj/logic.o:C:\nRF\Project\ble_bse/sdclog.h:22: multiple definition of `log_records_written'; Output/ble_bse_pca10056_s140 Debug/Obj/main.o:C:\nRF\Project\ble_bse/sdclog.h:22: first defined here
        Output/ble_bse_pca10056_s140 Debug/Obj/rs485.o:C:\nRF\Project\ble_bse/data.h:131: multiple definition of `ipn_messages_timeout'; Output/ble_bse_pca10056_s140 Debug/Obj/main.o:C:\nRF\Project\ble_bse/data.h:131: first defined here
        Output/ble_bse_pca10056_s140 Debug/Obj/rs485.o:C:\nRF\Project\ble_bse/data.h:132: multiple definition of `pro_remote_timeout'; Output/ble_bse_pca10056_s140 Debug/Obj/main.o:C:\nRF\Project\ble_bse/data.h:132: first defined here
        Output/ble_bse_pca10056_s140 Debug/Obj/rs485.o:C:\nRF\Project\ble_bse/data.h:133: multiple definition of `ucm_timeout'; Output/ble_bse_pca10056_s140 Debug/Obj/main.o:C:\nRF\Project\ble_bse/data.h:133: first defined here
        Output/ble_bse_pca10056_s140 Debug/Obj/rs485.o:C:\nRF\Project\ble_bse/ipn.h:238: multiple definition of `ipn_state'; Output/ble_bse_pca10056_s140 Debug/Obj/main.o:C:\nRF\Project\ble_bse/ipn.h:238: first defined here
        Output/ble_bse_pca10056_s140 Debug/Obj/sdcard.o:C:\nRF\Project\ble_bse/sdcard.h:39: multiple definition of `sdc_card_inserted'; Output/ble_bse_pca10056_s140 Debug/Obj/main.o:C:\nRF\Project\ble_bse/sdcard.h:39: first defined here
        Output/ble_bse_pca10056_s140 Debug/Obj/sdcard.o:C:\nRF\Project\ble_bse/sdcard.h:40: multiple definition of `sdc_status'; Output/ble_bse_pca10056_s140 Debug/Obj/main.o:C:\nRF\Project\ble_bse/sdcard.h:40: first defined here
        Output/ble_bse_pca10056_s140 Debug/Obj/sdcard.o:C:\nRF\Project\ble_bse/sdcard.h:41: multiple definition of `sdc_msg'; Output/ble_bse_pca10056_s140 Debug/Obj/main.o:C:\nRF\Project\ble_bse/sdcard.h:41: first defined here
        Output/ble_bse_pca10056_s140 Debug/Obj/sdclog.o:C:\nRF\Project\ble_bse/sdcard.h:39: multiple definition of `sdc_card_inserted'; Output/ble_bse_pca10056_s140 Debug/Obj/main.o:C:\nRF\Project\ble_bse/sdcard.h:39: first defined here
        Output/ble_bse_pca10056_s140 Debug/Obj/sdclog.o:C:\nRF\Project\ble_bse/sdcard.h:40: multiple definition of `sdc_status'; Output/ble_bse_pca10056_s140 Debug/Obj/main.o:C:\nRF\Project\ble_bse/sdcard.h:40: first defined here
        Output/ble_bse_pca10056_s140 Debug/Obj/sdclog.o:C:\nRF\Project\ble_bse/sdcard.h:41: multiple definition of `sdc_msg'; Output/ble_bse_pca10056_s140 Debug/Obj/main.o:C:\nRF\Project\ble_bse/sdcard.h:41: first defined here
        Output/ble_bse_pca10056_s140 Debug/Obj/sdclog.o:C:\nRF\Project\ble_bse/data.h:131: multiple definition of `ipn_messages_timeout'; Output/ble_bse_pca10056_s140 Debug/Obj/main.o:C:\nRF\Project\ble_bse/data.h:131: first defined here
        Output/ble_bse_pca10056_s140 Debug/Obj/sdclog.o:C:\nRF\Project\ble_bse/data.h:132: multiple definition of `pro_remote_timeout'; Output/ble_bse_pca10056_s140 Debug/Obj/main.o:C:\nRF\Project\ble_bse/data.h:132: first defined here
        Output/ble_bse_pca10056_s140 Debug/Obj/sdclog.o:C:\nRF\Project\ble_bse/data.h:133: multiple definition of `ucm_timeout'; Output/ble_bse_pca10056_s140 Debug/Obj/main.o:C:\nRF\Project\ble_bse/data.h:133: first defined here
        Output/ble_bse_pca10056_s140 Debug/Obj/sdclog.o:C:\nRF\Project\ble_bse/sdclog.h:18: multiple definition of `one_min_ctr'; Output/ble_bse_pca10056_s140 Debug/Obj/main.o:C:\nRF\Project\ble_bse/sdclog.h:18: first defined here
        Output/ble_bse_pca10056_s140 Debug/Obj/sdclog.o:C:\nRF\Project\ble_bse/sdclog.h:19: multiple definition of `six_min_ctr'; Output/ble_bse_pca10056_s140 Debug/Obj/main.o:C:\nRF\Project\ble_bse/sdclog.h:19: first defined here
        Output/ble_bse_pca10056_s140 Debug/Obj/sdclog.o:C:\nRF\Project\ble_bse/sdclog.h:20: multiple definition of `logging_period'; Output/ble_bse_pca10056_s140 Debug/Obj/main.o:C:\nRF\Project\ble_bse/sdclog.h:20: first defined here
        Output/ble_bse_pca10056_s140 Debug/Obj/sdclog.o:C:\nRF\Project\ble_bse/sdclog.h:21: multiple definition of `log_period_ctr'; Output/ble_bse_pca10056_s140 Debug/Obj/main.o:C:\nRF\Project\ble_bse/sdclog.h:21: first defined here
        Output/ble_bse_pca10056_s140 Debug/Obj/sdclog.o:C:\nRF\Project\ble_bse/sdclog.h:22: multiple definition of `log_records_written'; Output/ble_bse_pca10056_s140 Debug/Obj/main.o:C:\nRF\Project\ble_bse/sdclog.h:22: first defined here
        Output/ble_bse_pca10056_s140 Debug/Obj/service_if.o:C:\nRF\Project\ble_bse/data.h:131: multiple definition of `ipn_messages_timeout'; Output/ble_bse_pca10056_s140 Debug/Obj/main.o:C:\nRF\Project\ble_bse/data.h:131: first defined here
        Output/ble_bse_pca10056_s140 Debug/Obj/service_if.o:C:\nRF\Project\ble_bse/data.h:132: multiple definition of `pro_remote_timeout'; Output/ble_bse_pca10056_s140 Debug/Obj/main.o:C:\nRF\Project\ble_bse/data.h:132: first defined here
        Output/ble_bse_pca10056_s140 Debug/Obj/service_if.o:C:\nRF\Project\ble_bse/data.h:133: multiple definition of `ucm_timeout'; Output/ble_bse_pca10056_s140 Debug/Obj/main.o:C:\nRF\Project\ble_bse/data.h:133: first defined here
        Output/ble_bse_pca10056_s140 Debug/Obj/service_if.o:C:\nRF\Project\ble_bse/ipn.h:238: multiple definition of `ipn_state'; Output/ble_bse_pca10056_s140 Debug/Obj/main.o:C:\nRF\Project\ble_bse/ipn.h:238: first defined here
        Output/ble_bse_pca10056_s140 Debug/Obj/service_if.o:C:\nRF\Project\ble_bse/sdcard.h:39: multiple definition of `sdc_card_inserted'; Output/ble_bse_pca10056_s140 Debug/Obj/main.o:C:\nRF\Project\ble_bse/sdcard.h:39: first defined here
        Output/ble_bse_pca10056_s140 Debug/Obj/service_if.o:C:\nRF\Project\ble_bse/sdcard.h:40: multiple definition of `sdc_status'; Output/ble_bse_pca10056_s140 Debug/Obj/main.o:C:\nRF\Project\ble_bse/sdcard.h:40: first defined here
        Output/ble_bse_pca10056_s140 Debug/Obj/service_if.o:C:\nRF\Project\ble_bse/sdcard.h:41: multiple definition of `sdc_msg'; Output/ble_bse_pca10056_s140 Debug/Obj/main.o:C:\nRF\Project\ble_bse/sdcard.h:41: first defined here
        Output/ble_bse_pca10056_s140 Debug/Obj/service_if.o:C:\nRF\Project\ble_bse/sdclog.h:18: multiple definition of `one_min_ctr'; Output/ble_bse_pca10056_s140 Debug/Obj/main.o:C:\nRF\Project\ble_bse/sdclog.h:18: first defined here
        Output/ble_bse_pca10056_s140 Debug/Obj/service_if.o:C:\nRF\Project\ble_bse/sdclog.h:19: multiple definition of `six_min_ctr'; Output/ble_bse_pca10056_s140 Debug/Obj/main.o:C:\nRF\Project\ble_bse/sdclog.h:19: first defined here
        Output/ble_bse_pca10056_s140 Debug/Obj/service_if.o:C:\nRF\Project\ble_bse/sdclog.h:20: multiple definition of `logging_period'; Output/ble_bse_pca10056_s140 Debug/Obj/main.o:C:\nRF\Project\ble_bse/sdclog.h:20: first defined here
        Output/ble_bse_pca10056_s140 Debug/Obj/service_if.o:C:\nRF\Project\ble_bse/sdclog.h:21: multiple definition of `log_period_ctr'; Output/ble_bse_pca10056_s140 Debug/Obj/main.o:C:\nRF\Project\ble_bse/sdclog.h:21: first defined here
        Output/ble_bse_pca10056_s140 Debug/Obj/service_if.o:C:\nRF\Project\ble_bse/sdclog.h:22: multiple definition of `log_records_written'; Output/ble_bse_pca10056_s140 Debug/Obj/main.o:C:\nRF\Project\ble_bse/sdclog.h:22: first defined here
    Build failed

    Just referring to the first linker error, I'm posting the 'data.h' file so that you can see the variable declaration/definition of 'ipn_messages_timeout'

    data.h

  • So, taking one at random, 

    Output/ble_bse_pca10056_s140 Debug/Obj/ipn.o:
      C:\nRF\Project\ble_bse/data.h:131: multiple definition of `ipn_messages_timeout'; 
      
    Output/ble_bse_pca10056_s140 Debug/Obj/main.o:
      C:\nRF\Project\ble_bse/data.h:131: first defined here

    You have ipn_messages_timeout from data.h being duplicated into ipn.o and main.o

    In data.h you have:

    uint32_t ipn_messages_timeout;
    uint32_t pro_remote_timeout;
    uint32_t ucm_timeout;

    As guessed early on, these are definitions - therefore, any .c file which #includes data.h will get those definitions.

    Thus if multiple .c files #include data.h, you will get multiple definitions - which is exactly what is happening.

    They need to be declarations - not definitions.

    And you will need to add a definition somewhere ...

    Again, see: c-faq.com/.../decldef.html

Related