EmbDev.net

Forum: ARM programming with GCC/GNU tools linker error


Author: Milos Savanovic (savana)
Posted on:

Rate this post
0 useful
not useful
I get following error message:

make all
..linking
arm-elf-ld -v -L"C:/Program Files/yagarto/arm-elf/lib" -Map
./exe/main.map -T./asm/cs5403m_flash.ld -nostartfiles -o ./exe/main.elf
./obj/heap.o ./obj/stack.o ./obj/init.o \
  ./obj/vectors.o ./obj/uart_api.o ./obj/timers_api.o ./obj/ssp_api.o
./obj/ssp_test.o \
  ./obj/rtc_api.o ./obj/psg.o ./obj/lcd_api.o ./obj/gpio_api.o
./obj/uart_control.o \
  ./obj/clksys_api.o ./obj/main.o
./obj/uart_api.o: In function `createUARTResponse':
./uart/uart_api.c:22: undefined reference to `memset'
./uart/uart_api.c:25: undefined reference to `memcpy'
./uart/uart_api.c:30: undefined reference to `memcpy'
./obj/timers_api.o: In function `StartTimer':
./timers/timers_api.c:191: undefined reference to `__udivsi3'
./timers/timers_api.c:292: undefined reference to `__udivsi3'
./timers/timers_api.c:349: undefined reference to `dd_rtc_CancelAlarm'
./timers/timers_api.c:351: undefined reference to `__udivsi3'
./timers/timers_api.c:362: undefined reference to `intc_if'
./timers/timers_api.c:362: undefined reference to `rtc_if'
./timers/timers_api.c:362: undefined reference to `core_if'
./obj/ssp_api.o: In function `sendSSPWord':
./ssp/ssp_api.c:314: undefined reference to `memcpy'
./obj/ssp_api.o: In function `sendSSPRawWord':
./ssp/ssp_api.c:321: undefined reference to `memcpy'
./obj/ssp_api.o: In function `sendSSPDummySequence':
./ssp/ssp_api.c:328: undefined reference to `memcpy'
./obj/ssp_api.o: In function `createSSPResponse':
./ssp/ssp_api.c:362: undefined reference to `memset'
./ssp/ssp_api.c:365: undefined reference to `memcpy'
./ssp/ssp_api.c:370: undefined reference to `memcpy'
./obj/ssp_api.o: In function `setSSPCoreDisableInterrupts':
./ssp/ssp_api.c:875: undefined reference to `core_if'
./obj/ssp_api.o: In function `setSSPCoreEnableInterrupts':
./ssp/ssp_api.c:906: undefined reference to `intc_if'
./ssp/ssp_api.c:906: undefined reference to `core_if'
./obj/ssp_api.o: In function `recvSSPWord':
./ssp/ssp_api.c:1011: undefined reference to `memset'
./ssp/ssp_api.c:1014: undefined reference to `memcpy'
./ssp/ssp_api.c:1020: undefined reference to `memcpy'
./obj/ssp_api.o: In function `initSSPFullSlave':
./ssp/ssp_api.c:1177: undefined reference to `core_if'
./ssp/ssp_api.c:1177: undefined reference to `intc_if'
./obj/ssp_api.o: In function `initSSPFullMaster':
./ssp/ssp_api.c:1237: undefined reference to `core_if'
./ssp/ssp_api.c:1237: undefined reference to `intc_if'
./obj/lcd_api.o: In function `createLCDResponse':
./lcd/lcd_api.c:78: undefined reference to `memset'
./lcd/lcd_api.c:81: undefined reference to `memcpy'
./obj/lcd_api.o: In function `createLCDResponseDMW':
./lcd/lcd_api.c:93: undefined reference to `memset'
./lcd/lcd_api.c:96: undefined reference to `memcpy'
./lcd/lcd_api.c:100: undefined reference to `memcpy'
./lcd/lcd_api.c:101: undefined reference to `memcpy'
./lcd/lcd_api.c:102: undefined reference to `memcpy'
./lcd/lcd_api.c:103: undefined reference to `memcpy'
./obj/lcd_api.o: In function `lcdClkFrequencyTest':
./lcd/lcd_api.c:671: undefined reference to `lcd_if'
./obj/lcd_api.o: In function `lcdBlinkFrequencyTest':
./lcd/lcd_api.c:692: undefined reference to `lcd_if'
./obj/lcd_api.o: In function `lcdModeCheckTest':
./lcd/lcd_api.c:712: undefined reference to `lcd_if'
./obj/lcd_api.o: In function `lcdBlinkOnTest':
./lcd/lcd_api.c:733: undefined reference to `lcd_if'
./obj/lcd_api.o: In function `lcdLcdonTest':
./lcd/lcd_api.c:754: undefined reference to `lcd_if'
./obj/lcd_api.o:./lcd/lcd_api.c:781: more undefined references to
`lcd_if' follow
./obj/gpio_api.o: In function `createGPIOResponse':
./gpio/gpio_api.c:22: undefined reference to `memset'
./gpio/gpio_api.c:25: undefined reference to `memcpy'
./obj/gpio_api.o: In function `gpioResetDefaultDataManual':
./gpio/gpio_api.c:164: undefined reference to `memcpy'
./gpio/gpio_api.c:165: undefined reference to `memcpy'
./gpio/gpio_api.c:166: undefined reference to `memcpy'
./gpio/gpio_api.c:167: undefined reference to `memcpy'
./obj/gpio_api.o:./gpio/gpio_api.c:168: more undefined references to
`memcpy' follow
./obj/uart_control.o: In function `createRAWResponse':
./control/uart_control.c:714: undefined reference to `memset'
./control/uart_control.c:719: undefined reference to `memcpy'
./obj/uart_control.o: In function `writeToMemory':
./control/uart_control.c:726: undefined reference to `memcpy'
./control/uart_control.c:727: undefined reference to `memcpy'
./obj/uart_control.o: In function `readFromMemory':
GNU ld version 2.17
./control/uart_control.c:734: undefined reference to `memcpy'
./obj/uart_control.o: In function `handleRAWCommand':
./control/uart_control.c:762: undefined reference to `memcpy'
./obj/uart_control.o:./control/uart_control.c:763: more undefined
references to `memcpy' follow
./obj/main.o: In function `bbtMain':
./_main/main.c:78: undefined reference to `rtc_if'
make: *** [exe/main.elf] Error 1


my makefile looks as follows:

NAME   = cs5403_temp

CC      = arm-elf-gcc
LD      = arm-elf-ld -v
AR      = arm-elf-ar
AS      = arm-elf-as
CP      = arm-elf-objcopy
OD    = arm-elf-objdump -p
NM    = arm-elf-nm

OBJ_DIR = ./obj
EXE_DIR = ./exe
ASM_DIR = ./asm
SOURCE_DIR = ./_main
UART_DIR = ./uart
TIMERS_DIR = ./timers
SSP_DIR = ./ssp
RTC_DIR = ./rtc
PSG_DIR = ./psg
LCD_DIR = ./lcd
GPIO_DIR = ./gpio
FLASH_DIR = ./flash
CONTROL_DIR = ./control
CLKSYS_DIR = ./clksys
LIB_DIR = "C:/Program Files/yagarto/arm-elf/lib"
LIBGCC_DIR = "C:\Program Files\yagarto\lib\gcc\arm-elf\4.2.1"


LDSCRIPT = $(ASM_DIR)/cs5403m_flash.ld

CFLAGS  = -I"C:\Program Files\yagarto\lib\gcc\arm-elf\4.2.1\include"
-I"D:\savanovic\ARM\workspace\dev\include\regs"
-I"D:\savanovic\ARM\workspace\dev\include" -I./ -c -fno-common -O0 -g
AFLAGS = -Wa -ahls -mcpu=arm7  -o
LFLAGS  = -L"C:/Program Files/yagarto/arm-elf/lib" -Map
$(EXE_DIR)/main.map -T$(LDSCRIPT) -nostartfiles
CPFLAGS = -O binary
ODFLAGS  = -h -S -C
NMFLAGS = -n
all: test

clean:
  -rm -f $(OBJ_DIR)/*.lst $(OBJ_DIR)/*.o $(EXE_DIR)/main.elf
$(EXE_DIR)/main.hex $(EXE_DIR)/main.map \
  $(EXE_DIR)/main.dmp $(EXE_DIR)/main.bin $(EXE_DIR)/main.lss
$(EXE_DIR)/main.sym

test: $(EXE_DIR)/main.elf
  @ echo "...copying"
  $(CP) $(CPFLAGS) $(EXE_DIR)/main.elf $(EXE_DIR)/main.bin
  $(OD) $(ODFLAGS) $(EXE_DIR)/main.elf > $(EXE_DIR)/main.lss
  $(NM) $(NMFLAGS) $(EXE_DIR)/main.elf > $(EXE_DIR)/main.sym
  @ echo "done"

$(EXE_DIR)/main.elf: $(OBJ_DIR)/heap.o $(OBJ_DIR)/stack.o
$(OBJ_DIR)/init.o $(OBJ_DIR)/vectors.o \
  $(OBJ_DIR)/uart_api.o $(OBJ_DIR)/timers_api.o $(OBJ_DIR)/ssp_api.o
$(OBJ_DIR)/ssp_test.o \
  $(OBJ_DIR)/rtc_api.o $(OBJ_DIR)/psg.o $(OBJ_DIR)/lcd_api.o
$(OBJ_DIR)/gpio_api.o $(OBJ_DIR)/uart_control.o \
  $(OBJ_DIR)/clksys_api.o $(OBJ_DIR)/main.o $(LDSCRIPT)
  @ echo "..linking"
  $(LD) $(LFLAGS) -o $(EXE_DIR)/main.elf $(OBJ_DIR)/heap.o
$(OBJ_DIR)/stack.o $(OBJ_DIR)/init.o \
  $(OBJ_DIR)/vectors.o $(OBJ_DIR)/uart_api.o $(OBJ_DIR)/timers_api.o
$(OBJ_DIR)/ssp_api.o $(OBJ_DIR)/ssp_test.o \
  $(OBJ_DIR)/rtc_api.o $(OBJ_DIR)/psg.o $(OBJ_DIR)/lcd_api.o
$(OBJ_DIR)/gpio_api.o $(OBJ_DIR)/uart_control.o \
  $(OBJ_DIR)/clksys_api.o $(OBJ_DIR)/main.o

$(OBJ_DIR)/heap.o: $(ASM_DIR)/heap.s
  @ echo ".assembling"
  $(AS) $(AFLAGS) $(OBJ_DIR)/heap.o $(ASM_DIR)/heap.s >
$(OBJ_DIR)/heap.lst

$(OBJ_DIR)/stack.o: $(ASM_DIR)/stack.s
  @ echo ".assembling"
  $(AS) $(AFLAGS) $(OBJ_DIR)/stack.o $(ASM_DIR)/stack.s >
$(OBJ_DIR)/stack.lst

$(OBJ_DIR)/init.o: $(ASM_DIR)/init.s
  @ echo ".assembling"
  $(AS) $(AFLAGS) $(OBJ_DIR)/init.o $(ASM_DIR)/init.s >
$(OBJ_DIR)/init.lst

$(OBJ_DIR)/vectors.o: $(ASM_DIR)/vectors.s
  @ echo ".assembling"
  $(AS) $(AFLAGS) $(OBJ_DIR)/vectors.o $(ASM_DIR)/vectors.s >
$(OBJ_DIR)/vectors.lst

$(OBJ_DIR)/uart_api.o: $(UART_DIR)/uart_api.c
  @ echo ".compiling"
  $(CC) $(CFLAGS) -o $(OBJ_DIR)/uart_api.o $(UART_DIR)/uart_api.c

$(OBJ_DIR)/timers_api.o: $(TIMERS_DIR)/timers_api.c
  @ echo ".compiling"
  $(CC) $(CFLAGS) -o $(OBJ_DIR)/timers_api.o $(TIMERS_DIR)/timers_api.c

$(OBJ_DIR)/ssp_api.o: $(SSP_DIR)/ssp_api.c
  @ echo ".compiling"
  $(CC) $(CFLAGS) -o $(OBJ_DIR)/ssp_api.o $(SSP_DIR)/ssp_api.c

$(OBJ_DIR)/ssp_test.o: $(SSP_DIR)/ssp_test.c
  @ echo ".compiling"
  $(CC) $(CFLAGS) -o $(OBJ_DIR)/ssp_test.o $(SSP_DIR)/ssp_test.c

$(OBJ_DIR)/rtc_api.o: $(RTC_DIR)/rtc_api.c
  @ echo ".compiling"
  $(CC) $(CFLAGS) -o $(OBJ_DIR)/rtc_api.o $(RTC_DIR)/rtc_api.c

$(OBJ_DIR)/psg.o: $(PSG_DIR)/psg.c
  @ echo ".compiling"
  $(CC) $(CFLAGS) -o $(OBJ_DIR)/psg.o $(PSG_DIR)/psg.c

$(OBJ_DIR)/lcd_api.o: $(LCD_DIR)/lcd_api.c
  @ echo ".compiling"
  $(CC) $(CFLAGS) -o $(OBJ_DIR)/lcd_api.o $(LCD_DIR)/lcd_api.c

$(OBJ_DIR)/gpio_api.o: $(GPIO_DIR)/gpio_api.c
  @ echo ".compiling"
  $(CC) $(CFLAGS) -o $(OBJ_DIR)/gpio_api.o $(GPIO_DIR)/gpio_api.c

$(OBJ_DIR)/uart_control.o: $(CONTROL_DIR)/uart_control.c
  @ echo ".compiling"
  $(CC) $(CFLAGS) -o $(OBJ_DIR)/uart_control.o
$(CONTROL_DIR)/uart_control.c

$(OBJ_DIR)/clksys_api.o: $(CLKSYS_DIR)/clksys_api.c
  @ echo ".compiling"
  $(CC) $(CFLAGS) -o $(OBJ_DIR)/clksys_api.o $(CLKSYS_DIR)/clksys_api.c

$(OBJ_DIR)/main.o: $(SOURCE_DIR)/main.c
  @ echo ".compiling"
  $(CC) $(CFLAGS) -o $(OBJ_DIR)/main.o $(SOURCE_DIR)/main.c


Can anyone help me or at least let me know where to look for answer.
Thanks
Savana

Author: Jonathan Dumaresq (dumarjo)
Posted on:

Rate this post
0 useful
not useful
Milos Savanovic wrote:
> I get following error message:
>
> make all
> ..linking
> arm-elf-ld -v -L"C:/Program Files/yagarto/arm-elf/lib" -Map
> ./exe/main.map -T./asm/cs5403m_flash.ld -nostartfiles -o ./exe/main.elf
> ./obj/heap.o ./obj/stack.o ./obj/init.o \
>   ./obj/vectors.o ./obj/uart_api.o ./obj/timers_api.o ./obj/ssp_api.o
> ./obj/ssp_test.o \
>   ./obj/rtc_api.o ./obj/psg.o ./obj/lcd_api.o ./obj/gpio_api.o
> ./obj/uart_control.o \
>   ./obj/clksys_api.o ./obj/main.o

The best thing to do is to use the latest makefil from the gamma sample
from this site.

I think you need to add the -lc -lgcc to your linker argument.

Jonathan

Author: Martin Thomas (mthomas) (Moderator)
Posted on:

Rate this post
0 useful
not useful
As Jonathan alread mentioned the error-messages indicate that the libgcc
(i.e. for __udivsi3) and the libc (i.e. for memset) are not linked.

Also try to link through the compiler-frontend (use arm-elf-gcc not
arm-elf-ld). The frontend "knows" where to find the needed libraries so
not path has to be passed to the linker. Most (all) of the examples from
my "WinARM-pages" show how this can be done and can be used as
templates.

Author: Milos Savanovic (savana)
Posted on:

Rate this post
0 useful
not useful
Thanks guys. I solved the problem. I appreciate your help.

Reply

Entering an e-mail address is optional. If you want to receive reply notifications by e-mail, please log in.

Rules — please read before posting

  • Post long source code as attachment, not in the text
  • Posting advertisements is forbidden.

Formatting options

  • [c]C code[/c]
  • [avrasm]AVR assembler code[/avrasm]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]




Bild automatisch verkleinern, falls nötig
Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.