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

about the link error with arm-none-eabi on the eclipse environment.

Hello all

I'm struggling with link errors, "undefined referencce atan2" as well as all math library. I still dont know why it is occurred these errors. I configured the eclipse compile environment with the gnu arm tool using your doc, application note ver1.2. May you help me?

Parents
  • You need to tell the linker to actually link in the math library (libm). The header include only includes the declaration, but then of course at link time the code won't be included if you don't tell the linker. Different than the C standard library, math.h constitutes an additional library which the linker won't include by default.

    If you are using a makefile that is based on Nordic's GCC / GNU make makefile, simply add

    LIBS = -lm

    or

    LIBS += -lm

    in your makefile.

    The example makefile from Nordic does include $(LIBS) in the targets, but LIBS is never defined. You of course need to use the second variant if you defined LIBS yourself.

Reply
  • You need to tell the linker to actually link in the math library (libm). The header include only includes the declaration, but then of course at link time the code won't be included if you don't tell the linker. Different than the C standard library, math.h constitutes an additional library which the linker won't include by default.

    If you are using a makefile that is based on Nordic's GCC / GNU make makefile, simply add

    LIBS = -lm

    or

    LIBS += -lm

    in your makefile.

    The example makefile from Nordic does include $(LIBS) in the targets, but LIBS is never defined. You of course need to use the second variant if you defined LIBS yourself.

Children
No Data
Related