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

Segger Embedded Studio Link Errors - Undefined References

First - thanks to those who answered my question about the Segger Embedded Studio code size limit.  It appears to have be fixed when I switch the build configuration from "Internal and External" to just "Internal".  

This question may relate to the SDK rather than the Segger Embedded Studio, but my project did compile, link, and run with IAR and now I am getting these link errors with SES.  

Linking hm_chair.elf

_build/nrf_sdh.o:(.rodata.sdh_req_observers+0x0): undefined reference to `__start_sdh_req_observers'

_build/nrf_sdh.o:(.rodata.sdh_req_observers+0x4): undefined reference to `__stop_sdh_req_observers'

_build/nrf_sdh.o:(.rodata.sdh_state_observers+0x0): undefined reference to `__start_sdh_state_observers'

_build/nrf_sdh.o:(.rodata.sdh_state_observers+0x4): undefined reference to `__stop_sdh_state_observers'

  • Hi,

    I am not that familiar with porting projects from IAR to SES, but may it be that you still have old object files laying around so now you try to link object files from IAR with object files from SES?

    If so, cleaning the solution should get rid of the old object files so that you can do a clean build using the SES toolchain.

    Regards,
    Terje

  • Thanks for the reply.  I tried to use the build menu and select Clean for both this project name and then Solution (which appears to be there for all projects) and rebuilt.  The same four undefined references show up at the link step.

  • put "section variables segger embedded" into the search box and that will give you a mixed bag of posts, some of which explain how section variables work and how you need to add extra sections to the linker script and load code. 

    Regrettably section variables are one of those things which IAR's auto-section-creation makes work out of the box so someone used them a couple of years ago. They are a pain however under gcc and other non IAR  toolchains which require them added to the ld script (for gcc) or the xml file which generates the ld script for SES/crossworks and also, since they have defined initial values, a chunk of code to the loader stub to populate them. 

    I haven't seen nor thought up a better solution to this for SES. 

  • I think your suggestion to look at section variables is going to lead me to the fix.  I have not gotten a compile yet, but I do notice that sdh_req_observers (one of the undefined reference errors) is in a section called sdh_req_observers that is created using the NRF_SECTION_SET_DEF call in nrf_sdh.c.  

    On more basic level for someone new to the Segger Embedded Studio, which project file is the makefile?  When I browse the project directory, there are numerous files with the name Makefile.

  • I do not quite understand what you mean by "which project file is the makefile?" Often makefiles are used for the GCC toolchain, but instead SES has its own project file (ending in .emProject) which is really an xml file containing include paths, files, defines, options, etc.

    For makefiles it is not uncommon that one Makefile includes another (or even several other) Makefiles.

Related