• Join
  • Sign In with my.TI Login
Texas Instruments
  • Products
  • Applications
  • Tools & Software
  • Support & Community
  • Sample & Buy
  • About TI
Sample & Purchase Cart Sample & Purchase Cart
  • Search
  • Advanced
TI E2E™ Community
  • Support Forums
  • Blogs
  • Groups
  • Videos
  • 简体中文
  • More ...
TI Home » TI E2E Community » Support Forums » Microcontrollers » Stellaris® ARM® Microcontrollers » Stellaris® ARM® LM3S Microcontrollers Forum » gcc, undefined reference to 'log'
Share
Stellaris® ARM® Microcontrollers
  • Forum
Options
  • Subscribe via RSS
Helpful Stellaris® LM4F Series Links
  • LM4F Series
  • Stellaris PinMux Utility
  • Stellaris® LM4F120 LaunchPad
  • LM4F MCU Applications
  • LM4F MCU Video
  • ARM Cortex-M4F Whitepaper
  • Stellaris MCU Brochure
  • LM4F232 Eval Kit
  • gcc, undefined reference to 'log'

    gcc, undefined reference to 'log'

    • eccarm
      Posted by eccarm
      on Mar 31 2008 10:25 AM
      Prodigy60 points
      Hello all.
      I'm trying to compile code with the 'log' function using sourcery g++ lite tools. It compiles ok and finds , but gets an error during link:

      $ make
      CC test.c
      LD gcc/test.axf
      gcc/test.o: In function `main':
      test.c:(.text+0x632): undefined reference to `log'
      test.c:(.text+0x63e): undefined reference to `log'
      test.c:(.text+0x646): undefined reference to `pow'
      make: *** [gcc/test.axf] Error 1

      I'm using the standard makedef file that is included with the DriverLib stuff. Doing a quick google of this problem, it seems that the "-lm" flag needs to be included to pull in the math library.

      However, when I add -lm to CFLAGS in the makedef, I get the same error. Has anyone else ran into this problem?
      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • eccarm
      Posted by eccarm
      on Mar 31 2008 17:47 PM
      Prodigy60 points
      Turns out that -lm likes to be at the end of the command, not in with the LDFLAGS. With that fixed, I am now the proud recipient of a new and different error:

      $ make
      arm-none-eabi-ld -T ../../Driverlib/gcc/standalone.ld --entry ResetISR --gc-sections -o gcc/test.axf gcc/gdb.o gcc/dhcp.o gcc/uartstdio.o gcc/test.o gcc/etharp.o gcc/httpd.o gcc/ctrl.o gcc/icmp.o gcc/inet.o gcc/ip.o gcc/ip_addr.o gcc/fs_test.o gcc/luminaryif.o gcc/mem.o gcc/memp.o gcc/netif.o gcc/pbuf.o gcc/raw.o gcc/rit128x96x4.o gcc/startup_gcc.o gcc/stats.o gcc/sys.o gcc/tcp.o gcc/tcp_in.o gcc/tcp_out.o gcc/udp.o gcc/ustdlib.o ../../Driverlib/src/gcc/libdriver.a c:/program files/codesourcery/sourcery g++ lite/bin/../lib/gcc/arm-none-eabi/4.2.1/../../../../arm-none-eabi/lib/thumb2/libc.a c:/program files/codesourcery/sourcery g++ lite/bin/../lib/gcc/arm-none-eabi/4.2.1/thumb2/libgcc.a -lm
      c:program filescodesourcerysourcery g++ litebin../arm-none-eabi/liblibm.a(lib_a-w_log.o): In function `log':
      w_log.c:(.text+0x128): undefined reference to __errno'
      w_log.c:(.text+0x138): undefined reference to __errno'
      w_log.c:(.text+0x148): undefined reference to __errno'
      c:program files/codesourcerysourcery g++ lite/bin/../arm-none-eabi/liblibm.a(lib_a-w_pow.o): In function `pow':
      w_pow.c:(.text+0x15c): undefined reference to __errno'
      w_pow.c:(.text+0x214): undefined reference to __errno'
      c:program files/codesourcerysourcery g++ lite/bin/../arm-none-eabi/liblibm.a(lib_a-w_pow.o):w_pow.c:(.text+0x2b0): more undefined references to `__errno' follow
      make: *** [gcc/test.axf] Error 1


      I also tried pointing to yadayada/arm-none-eabi/lib/thumb2/libm.a instead of using -lm (similar to libc and libgcc), but same results.

      Any help is much appreciated!

      Post edited by: ajmuff, at: 2008/04/01 08:44
      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • eccarm
      Posted by eccarm
      on Apr 03 2008 17:09 PM
      Prodigy60 points
      This issue was resolved from a fast response on the Sourcery G++ Lite mail list:


      We advise customers to link with "arm-none-eabi-gcc", not
      "arm-none-eabi-ld". If you use "ld", you have to manually pull in all
      the libraries that "gcc" will automatically include.

      However, in your case, you probably just need to put libm before libgcc.
      The linker only pulls code out of a library if it knows it's needed at
      that point in processing the command line.


      So my new makedef looks like this, which cleaned up all of the errors:
      ${LD} -T $${ldname}
      --entry ${ENTRY_${notdir ${@:.axf=}}}
      ${LDFLAGSgcc_${notdir ${@:.axf=}}}
      ${LDFLAGS} -o ${@} $(filter %.o %.a, ${^})
      -lm '${LIBC}' '${LIBGCC}'
      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    TI E2E™ Community
    • Support Forums
    • Blogs
    • Videos
    • Groups
    • Site Support & Feedback
    • Settings
    TI E2E™ Community Groups
    • TI University Program
    • Make the Switch
    • Microcontroller Projects
    • Motor Drive & Control
    Other Communities
    • Deyisupport
    • Designsomething.org
    • beagleboard.org
    • TI on Element 14
    • TI on TechXchangeSM
    Other Technical & Support Resources
    • WEBENCH® Design Center
    • Product Information Centers
    • Technical Documents
    • TI Design Network
    • TI Technical Articles
    • TI Training

    All content and materials on this site are provided "as is". TI and its respective suppliers and providers of content make no representations about the suitability of these materials for any purpose and disclaim all warranties and conditions with regard to these materials, including but not limited to all implied warranties and conditions of merchantability, fitness for a particular purpose, title and non-infringement of any third party intellectual property right. TI and its respective suppliers and providers of content make no representations about the suitability of these materials for any purpose and disclaim all warranties and conditions with respect to these materials. No license, either express or implied, by estoppel or otherwise, is granted by TI. Use of the information on this site may require a license from a third party, or a license from TI.

    Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Terms of Use of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Terms of Use of this site. TI, its suppliers and providers of content reserve the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.

    Follow Us Texas Instruments on Facebook Texas Instruments on Twitter Texas Instruments on LinkedIn Texas Instruments on Google+
    TI Worldwide | Contact Us | my.TI Login | Site Map | Corporate Citizenship | mobile m.ti.com (Mobile Version)

    TI is a global semiconductor design and manufacturing company. Innovate with 100,000+ analog ICs and
    embedded processors, along with software, tools and the industry’s largest sales/support staff.

    © Copyright 1995-2013 Texas Instruments Incorporated. All rights reserved.
    Trademarks | Privacy Policy | Terms of Use