Eclipse and yagarto - problem linking libraries in makefile

Hello everybody,

i tried to compile an example program for my lpc2378 stk board and in the beginning it worked.

Then I wanted to use floating operations and now i’m getting following errors :

F:\games(E)_zaPodrejdane\ARM_Proba\opit1/main.c:200: undefined reference to `__aeabi_i2d’

F:\games(E)_zaPodrejdane\ARM_Proba\opit1/main.c:200: undefined reference to `__aeabi_ddiv’

F:\games(E)_zaPodrejdane\ARM_Proba\opit1/main.c:200: undefined reference to `__aeabi_d2f’

F:\games(E)_zaPodrejdane\ARM_Proba\opit1/main.c:201: undefined reference to `__aeabi_fmul’

and the code in my main.c:

voltageValueF = voltageValue / 3.3;
voltageValueF *= 1024;

I think this is a linking error.I’m not sure that i have included the library correct or the correct library in my makefile.

Please anyone who knows just take a look at my makefile and tell me what’s wrong there. I’m trying to fix this the whole day… :shock:

My makefile is as follows:

NAME   = lpc_p2378

CC      = arm-none-eabi-gcc
LD      = arm-none-eabi-ld -v 
AR      = arm-none-eabi-ar
AS      = arm-none-eabi-as
CP      = arm-none-eabi-objcopy
OD		= arm-none-eabi-objdump

CFLAGS  = -mcpu=arm7tdmi -I./ -c -fno-common -O0 -g -I"G:\yagarto\arm-none-eabi\include"
AFLAGS  = -ahls -mapcs-32 -o crt.o
LFLAGS  = -Map main.map -T2378_demo.cmd 
LINK_LIBS = -Lg:/yagarto/arm-none-eabi/lib -lc -lm -lg 
CPFLAGS = -O binary
HEXFLAGS = -O ihex
ODFLAGS	= -x --syms

all: test

clean:
	-rm crt.lst crt.o clock.o uart.o main.o main.out main.map main.dmp main.bin

test: main.out
	@ echo "...copying"
	$(CP) $(CPFLAGS) main.out main.bin
	$(OD) $(ODFLAGS) main.out > main.dmp
	@echo "...building hex"
	$(CP) $(HEXFLAGS) main.out main.hex

main.out: crt.o adc.o clock.o uart.o main.o 2378_demo.cmd 
	@ echo "..linking"
	$(LD) $(LFLAGS) -o main.out  crt.o main.o clock.o uart.o adc.o $(LINK_LIBS)

crt.o: crt.s
	@ echo ".assembling"
	$(AS) $(AFLAGS) crt.s > crt.lst

uart.o: uart.c
	@ echo ".compiling uart"
	$(CC) $(CFLAGS) uart.c
		
clock.o: clock.c
	@ echo ".compiling clock"
	$(CC) $(CFLAGS) clock.c
	
adc.o: adc.c
	@ echo ".compiling adc"
	$(CC) $(CFLAGS) adc.c

main.o: main.c
	@ echo ".compiling"
	$(CC) $(CFLAGS) main.c

I tried to use the option ‘-Wl’ as well but the linker didn’t recognize it.

Thank you in advance for your help!

Hello Kostadin,

It turns out that the floating point arithmetic is in libgcc.

It also turns out that you and I are not the only two who have struggled with this. The author of the pages at [fun-tech.se has a solution.

Or you can use ld and link with libgcc. Something like:

LINK_LIBS = -Lg:/yagarto/arm-none-eabi/lib -Lg:/yagarto/lib/arm-none-eabi/4.2.2 -lc -lm -lg -lgcc
  • - Replace the 4.2.2 with your version of gcc
  • - you might need arm-elf instead of arm-none-eabi ?
  • - Depending on your situation, you might want to use a subdirectory of [4.2.2], for example 4.2.2/thumb. But I believe arm7tdmi is the "plain vanilla" architecture supported by the flavor of libgcc in the main directory.
  • -Hugh](The float ld problem)

    Hello hsutherl,

    thank you very much for your help! The solution was just to add the right library :oops: - libgcc :

    LINK_LIBS = -Lg:/yagarto/arm-none-eabi/lib -lc -lm -lg -LG:/yagarto/lib/gcc/arm-none-eabi/4.7.2 -lgcc
    

    I was sure yesterday that i tried all possible libraries, but one never knows.

    The new version of yagarto uses arm-none-eabi instead of arm-elf.

    Software.

    One recommendation I will make is stop using ld to link - use gcc for both compile and link. Using GCC the correct multilibs will be selected.

    Spen

    The use of gcc for link does seem cleaner and less error prone. I finally switched over to that approach. Thanks Spen!

    This relieved me of the need to specify the exact flavor and location of libgcc.a. In retrospect, it should have been obvious that I had to give gcc some information so that it could figure out which library to use. As it was, I traced my hardfaults back to some mysterious BLX instructions and then scratched my head for a while (the individual object files all had BL, not BLX). Once I added my architecture options (-mthumb -mcpu=cortex-m3 -mfloat-abi=soft) to the link command, all was well.

    -Hugh