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

Undefined reference for round function within Mesh SDK

Hi,

I am trying to port an existing project to a Mesh SDK example.
Some files include the math.h library and use the round function.
During the build process I am getting the following message:
undefined reference to `round'

I tried the solution shown in:
https://devzone.nordicsemi.com/f/nordic-q-a/44735/configure-math-h-lib-with-cmake-on-sdk-mesh/175761#175761

But adding the library manually doesnt work for me:

set(MATH_LINK_LIBRARY ${MATH_LINK_LIBRARY} ${SDK_ROOT}/components/toolchain/cmsis/dsp/GCC/libarm_cortexM4f_math.a)

target_link_libraries(${target}
    rtt_${PLATFORM}
    uECC_${PLATFORM}
    ${MATH_LINK_LIBRARY})

CMake does not find the library:

CMake Error at CMake/GenerateSESProject.cmake:22 (get_property):
  get_property could not find TARGET
  /home/nrf5/nRF5_SDK_15.3.0_59ac345/components/toolchain/cmsis/dsp/GCC/libarm_cortexM4f_math.a.
  Perhaps it has not yet been created.

Does anybody know a solution?
Thanks in advance

Parents
  • usually adding "-lm" to the link is all you have needed to link functions in math.h for decades. That should get gcc to select and link the correct library automatically. 

  • thank you for the response,
    I have tried adding the libmath within the cmake file without success

    CMake Error at CMake/GenerateSESProject.cmake:21 (get_property):
      get_property could not find TARGET m.  Perhaps it has not yet been created.

    I also tried modifying the link flags within the cmake toolchain files without success.

    Now I switched to the Segger IDE, and it compiles without errors.

  • there is no 'libmath' and you can't add 'm' as a target because it isn't a target. You just need to work out how to add '-lm' to your link flags. I'd go read some cmake tutorials, however before you do that, find the link line which is failing, the whole command, probably several lines long, the one which gives you the error that 'round' isn't found. Copy and paste it, you'll get the same error, then add -lm in and see if it works. If it does you just need to work out how to get cmake to add that flag. 

Reply
  • there is no 'libmath' and you can't add 'm' as a target because it isn't a target. You just need to work out how to add '-lm' to your link flags. I'd go read some cmake tutorials, however before you do that, find the link line which is failing, the whole command, probably several lines long, the one which gives you the error that 'round' isn't found. Copy and paste it, you'll get the same error, then add -lm in and see if it works. If it does you just need to work out how to get cmake to add that flag. 

Children
No Data
Related