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'
Posted by
eccarm
on
Mar 31 2008 10:25 AM
Prodigy
60
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.
Posted by
eccarm
on
Mar 31 2008 17:47 PM
Prodigy
60
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.
Posted by
eccarm
on
Apr 03 2008 17:09 PM
Prodigy
60
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.