How to call a standart C library form a Makefile ?

Started by Vince, July 05, 2013, 03:26:52 PM

Previous topic - Next topic

Vince

Hi everybody !

At first I work on a STM32-E407 board, with Eclipse and Yagarto.
Since yesterday I research how to use C function like prinft or scanf for example. So I included the stdio.h library from Yagarto.

To communicate with my computer, I use the USART3 via a USB serial cable, connected on BOOT connector. It work, and I decided to create a new function fputc into the main.c. (Someone know what is better to use between the fputc() and the putchar() function ?)

int fputc(int c, FILE * f){
USART_SendData(USART3, (u8) c);
while(USART_GetFlagStatus(USART3, USART_FLAG_TXE) == RESET);
return c;
}


Finally I called the printf() function, obviously it didn't work. After some Google research I found out that I had to link "libg.a".  So I copied this library form the yagarto directory to my build directory and I changed my Makefile :


# Makefile for compiling the Getting Started project

#-------------------------------------------------------------------------------
# User-modifiable options
#-------------------------------------------------------------------------------

# Trace level used for compilation
# (can be overriden by adding TRACE_LEVEL=#number to the command-line)
# TRACE_LEVEL_DEBUG      5
# TRACE_LEVEL_INFO       4
# TRACE_LEVEL_WARNING    3
# TRACE_LEVEL_ERROR      2
# TRACE_LEVEL_FATAL      1
# TRACE_LEVEL_NO_TRACE   0
TRACE_LEVEL = 4

# Optimization level
OPTIMIZATION = -O0

# Output file basename
OUTPUT = main

# Output directories
BIN = .
OBJ = obj

# library dirs
LIBRARYSRC = ./lib/src

STARTUPFILE = ./lib/startup_stm32f4xx.s

#-------------------------------------------------------------------------------
# Tools
#-------------------------------------------------------------------------------

# Tool suffix when cross-compiling
CROSS_COMPILE = arm-none-eabi-

CC = $(CROSS_COMPILE)gcc
SIZE = $(CROSS_COMPILE)size
STRIP = $(CROSS_COMPILE)strip
OBJCOPY = $(CROSS_COMPILE)objcopy
OBJDUMP = $(CROSS_COMPILE)objdump
LD = $(CROSS_COMPILE)ld
AS = $(CROSS_COMPILE)as

#-------------------------------------------------------------------------------
# Files
#-------------------------------------------------------------------------------

# include folders
INCLUDES = -I./
INCLUDES += -I./lib/
INCLUDES += -I./lib/inc/
INCLUDES += -I./lib/inc/../../

#INCLUDES += -I.C:/OlimexODS/yagarto-20121222/arm-none-eabi/lib
#INCLUDES += -I.C:/OlimexODS/yagarto-20121222/arm-none-eabi/sys-include
#INCLUDES += -I.C:/OlimexODS/yagarto-20121222/lib/gcc/arm-none-eabi/4.7.2/include
#INCLUDES += -I.C:/OlimexODS/yagarto-20121222/lib/gcc/arm-none-eabi/4.7.2/include-fixed

# Objects built from C source files
C_OBJECTS = $(OBJ)/main.o
C_OBJECTS += $(OBJ)/system_stm32f4xx.o
C_OBJECTS += $(OBJ)/misc.o
C_OBJECTS += $(OBJ)/stm32f4xx_gpio.o
C_OBJECTS += $(OBJ)/stm32f4xx_rcc.o
C_OBJECTS += $(OBJ)/stm32f4xx_tim.o
C_OBJECTS += $(OBJ)/stm32f4xx_usart.o
C_OBJECTS += $(OBJ)/stm32f4xx_it.o

# Objects built from Assembly source files
ASM_OBJECTS = $(OBJ)/startup_stm32f4xx.o

LINKER_SCRIPT = ./lib/stm32f4xx_flash.ld
#LINKER_SCRIPT = ./lib/stm32f4xx_flash_extsram.ld

# Append OBJ and BIN directories to output filename
OUTPUT := $(BIN)/$(OUTPUT)

#-------------------------------------------------------------------------------
# Rules
#-------------------------------------------------------------------------------

# Flags
CFLAGS = -Wall -fno-common -c -g -mcpu=cortex-m3 -mthumb
CFLAGS += -g $(OPTIMIZATION) $(INCLUDES) -DTRACE_LEVEL=$(TRACE_LEVEL)
ASFLAGS = -g -mapcs-32
LDFLAGS = -g -v -nostartfiles
OBJCOPYFLAGS = -O binary
OBJDUMPFLAGS = -x --syms -S

all: $(BIN) $(OBJ) $(OUTPUT).out

$(BIN) $(OBJ):
mkdir $@

$(OUTPUT).out: $(C_OBJECTS) $(ASM_OBJECTS) $(LINKER_SCRIPT)
@ echo "..linking"
$(LD) $(LDFLAGS) -Map $(OUTPUT).map -T$(LINKER_SCRIPT) -o $(OUTPUT).out $(C_OBJECTS) $(ASM_OBJECTS) libg.a libgcc.a
$(OBJCOPY) $(OBJCOPYFLAGS) $(OUTPUT).out $(OUTPUT).bin
#   $(OBJDUMP) $(OBJDUMPFLAGS) $(OUTPUT).out > $(OUTPUT).lss
@ echo "...completed."

$(C_OBJECTS): main.c system_stm32f4xx.c
@ echo ".compiling"
$(CC) $(CFLAGS) -o $(OBJ)/main.o main.c
$(CC) $(CFLAGS) -o $(OBJ)/system_stm32f4xx.o system_stm32f4xx.c
$(CC) $(CFLAGS) -o $(OBJ)/stm32f4xx_it.o stm32f4xx_it.c
@ echo ".compiling libraries"
$(CC) $(CFLAGS) -o $(OBJ)/misc.o $(LIBRARYSRC)/misc.c
$(CC) $(CFLAGS) -o $(OBJ)/stm32f4xx_gpio.o $(LIBRARYSRC)/stm32f4xx_gpio.c
$(CC) $(CFLAGS) -o $(OBJ)/stm32f4xx_tim.o $(LIBRARYSRC)/stm32f4xx_tim.c
$(CC) $(CFLAGS) -o $(OBJ)/stm32f4xx_usart.o $(LIBRARYSRC)/stm32f4xx_usart.c 
$(CC) $(CFLAGS) -o $(OBJ)/stm32f4xx_rcc.o $(LIBRARYSRC)/stm32f4xx_rcc.c
# $(CC) $(CFLAGS) -o $(OBJ)/syscalls.o lib/syscalls.c 

$(ASM_OBJECTS): $(STARTUPFILE)
@ echo ".assembling"
$(AS) $(ASFLAGS) -o $(OBJ)/startup_stm32f4xx.o $(STARTUPFILE)

clean:
-rm -f $(OBJ)/*.o $(BIN)/*.out $(BIN)/*.bin $(BIN)/*.dmp $(BIN)/*.map $(BIN)/*.lss


Now I have the following message from the compiler:

make all
.compiling
arm-none-eabi-gcc -Wall -fno-common -c -g -mcpu=cortex-m3 -mthumb -g -O0 -I./ -I./lib/ -I./lib/inc/ -I./lib/inc/../../ -DTRACE_LEVEL=4 -o obj/main.o main.c
arm-none-eabi-gcc -Wall -fno-common -c -g -mcpu=cortex-m3 -mthumb -g -O0 -I./ -I./lib/ -I./lib/inc/ -I./lib/inc/../../ -DTRACE_LEVEL=4 -o obj/system_stm32f4xx.o system_stm32f4xx.c
arm-none-eabi-gcc -Wall -fno-common -c -g -mcpu=cortex-m3 -mthumb -g -O0 -I./ -I./lib/ -I./lib/inc/ -I./lib/inc/../../ -DTRACE_LEVEL=4 -o obj/stm32f4xx_it.o stm32f4xx_it.c
.compiling libraries
arm-none-eabi-gcc -Wall -fno-common -c -g -mcpu=cortex-m3 -mthumb -g -O0 -I./ -I./lib/ -I./lib/inc/ -I./lib/inc/../../ -DTRACE_LEVEL=4 -o obj/misc.o ./lib/src/misc.c
arm-none-eabi-gcc -Wall -fno-common -c -g -mcpu=cortex-m3 -mthumb -g -O0 -I./ -I./lib/ -I./lib/inc/ -I./lib/inc/../../ -DTRACE_LEVEL=4 -o obj/stm32f4xx_gpio.o ./lib/src/stm32f4xx_gpio.c
arm-none-eabi-gcc -Wall -fno-common -c -g -mcpu=cortex-m3 -mthumb -g -O0 -I./ -I./lib/ -I./lib/inc/ -I./lib/inc/../../ -DTRACE_LEVEL=4 -o obj/stm32f4xx_tim.o ./lib/src/stm32f4xx_tim.c
arm-none-eabi-gcc -Wall -fno-common -c -g -mcpu=cortex-m3 -mthumb -g -O0 -I./ -I./lib/ -I./lib/inc/ -I./lib/inc/../../ -DTRACE_LEVEL=4 -o obj/stm32f4xx_usart.o ./lib/src/stm32f4xx_usart.c 
arm-none-eabi-gcc -Wall -fno-common -c -g -mcpu=cortex-m3 -mthumb -g -O0 -I./ -I./lib/ -I./lib/inc/ -I./lib/inc/../../ -DTRACE_LEVEL=4 -o obj/stm32f4xx_rcc.o ./lib/src/stm32f4xx_rcc.c
..linking
arm-none-eabi-ld -g -v -nostartfiles  -Map ./main.map -T./lib/stm32f4xx_flash.ld -o ./main.out obj/main.o obj/system_stm32f4xx.o obj/misc.o obj/stm32f4xx_gpio.o obj/stm32f4xx_rcc.o obj/stm32f4xx_tim.o obj/stm32f4xx_usart.o obj/stm32f4xx_it.o obj/startup_stm32f4xx.o libg.a libgcc.a
GNU ld (GNU Binutils) 2.23.1
libg.a(lib_a-vfprintf.o): In function `_vfprintf_r':
C:\msys\1.0\home\yagarto\newlib-build\arm-none-eabi\newlib\libc\stdio/../../../../../newlib-1.20.0/newlib/libc/stdio/vfprintf.c:1084: undefined reference to `__aeabi_dcmplt'
C:\msys\1.0\home\yagarto\newlib-build\arm-none-eabi\newlib\libc\stdio/../../../../../newlib-1.20.0/newlib/libc/stdio/vfprintf.c:1544: undefined reference to `__aeabi_dcmpeq'
C:\msys\1.0\home\yagarto\newlib-build\arm-none-eabi\newlib\libc\stdio/../../../../../newlib-1.20.0/newlib/libc/stdio/vfprintf.c:1591: undefined reference to `__aeabi_dcmpeq'
libg.a(lib_a-vfprintf.o): In function `cvt':
C:\msys\1.0\home\yagarto\newlib-build\arm-none-eabi\newlib\libc\stdio/../../../../../newlib-1.20.0/newlib/libc/stdio/vfprintf.c:1724: undefined reference to `__aeabi_dcmpeq'
C:\msys\1.0\home\yagarto\newlib-build\arm-none-eabi\newlib\libc\stdio/../../../../../newlib-1.20.0/newlib/libc/stdio/vfprintf.c:1720: undefined reference to `__aeabi_dcmpeq'
libg.a(lib_a-dtoa.o): In function `quorem':
C:\msys\1.0\home\yagarto\newlib-build\arm-none-eabi\newlib\libc\stdlib/../../../../../newlib-1.20.0/newlib/libc/stdlib/dtoa.c:60: undefined reference to `__aeabi_uidiv'
libg.a(lib_a-dtoa.o): In function `_dtoa_r':
C:\msys\1.0\home\yagarto\newlib-build\arm-none-eabi\newlib\libc\stdlib/../../../../../newlib-1.20.0/newlib/libc/stdlib/dtoa.c:282: undefined reference to `__aeabi_dcmpeq'
C:\msys\1.0\home\yagarto\newlib-build\arm-none-eabi\newlib\libc\stdlib/../../../../../newlib-1.20.0/newlib/libc/stdlib/dtoa.c:347: undefined reference to `__aeabi_ui2d'
.
.
.

.
.
.
C:\msys\1.0\home\yagarto\newlib-build\arm-none-eabi\newlib\libc\stdlib/../../../../../newlib-1.20.0/newlib/libc/stdlib/dtoa.c:359: undefined reference to `__aeabi_i2d'
C:\msys\1.0\home\yagarto\newlib-build\arm-none-eabi\newlib\libc\stdlib/../../../../../newlib-1.20.0/newlib/libc/stdlib/dtoa.c:359: undefined reference to `__aeabi_dcmpeq'
C:\msys\1.0\home\yagarto\newlib-build\arm-none-eabi\newlib\libc\stdlib/../../../../../newlib-1.20.0/newlib/libc/stdlib/dtoa.c:450: undefined reference to `__aeabi_ddiv'
C:\msys\1.0\home\yagarto\newlib-build\arm-none-eabi\newlib\libc\stdlib/../../../../../newlib-1.20.0/newlib/libc/stdlib/dtoa.c:457: undefined reference to `__aeabi_dmul'
C:\msys\1.0\home\yagarto\newlib-build\arm-none-eabi\newlib\libc\stdlib/../../../../../newlib-1.20.0/newlib/libc/stdlib/dtoa.c:459: undefined reference to `__aeabi_ddiv'
C:\msys\1.0\home\yagarto\newlib-build\arm-none-eabi\newlib\libc\stdlib/../../../../../newlib-1.20.0/newlib/libc/stdlib/dtoa.c:471: undefined reference to `__aeabi_dcmplt'
C:\msys\1.0\home\yagarto\newlib-build\arm-none-eabi\newlib\libc\stdlib/../../../../../newlib-1.20.0/newlib/libc/stdlib/dtoa.c:480: undefined reference to `__aeabi_i2d'
C:\msys\1.0\home\yagarto\newlib-build\arm-none-eabi\newlib\libc\stdlib/../../../../../newlib-1.20.0/newlib/libc/stdlib/dtoa.c:480: undefined reference to `__aeabi_dmul'
C:\msys\1.0\home\yagarto\newlib-build\arm-none-eabi\newlib\libc\stdlib/../../../../../newlib-1.20.0/newlib/libc/stdlib/dtoa.c:480: undefined reference to `__aeabi_dadd'
C:\msys\1.0\home\yagarto\newlib-build\arm-none-eabi\newlib\libc\stdlib/../../../../../newlib-1.20.0/newlib/libc/stdlib/dtoa.c:498: undefined reference to `__aeabi_ddiv'
C:\msys\1.0\home\yagarto\newlib-build\arm-none-eabi\newlib\libc\stdlib/../../../../../newlib-1.20.0/newlib/libc/stdlib/dtoa.c:498: undefined reference to `__aeabi_dsub'
C:\msys\1.0\home\yagarto\newlib-build\arm-none-eabi\newlib\libc\stdlib/../../../../../newlib-1.20.0/newlib/libc/stdlib/dtoa.c:501: undefined reference to `__aeabi_d2iz'
C:\msys\1.0\home\yagarto\newlib-build\arm-none-eabi\newlib\libc\stdlib/../../../../../newlib-1.20.0/newlib/libc/stdlib/dtoa.c:502: undefined reference to `__aeabi_i2d'
C:\msys\1.0\home\yagarto\newlib-build\arm-none-eabi\newlib\libc\stdlib/../../../../../newlib-1.20.0/newlib/libc/stdlib/dtoa.c:502: undefined reference to `__aeabi_dsub'
C:\msys\1.0\home\yagarto\newlib-build\arm-none-eabi\newlib\libc\stdlib/../../../../../newlib-1.20.0/newlib/libc/stdlib/dtoa.c:504: undefined reference to `__aeabi_dcmpgt'
C:\msys\1.0\home\yagarto\newlib-build\arm-none-eabi\newlib\libc\stdlib/../../../../../newlib-1.20.0/newlib/libc/stdlib/dtoa.c:506: undefined reference to `__aeabi_dsub'
C:\msys\1.0\home\yagarto\newlib-build\arm-none-eabi\newlib\libc\stdlib/../../../../../newlib-1.20.0/newlib/libc/stdlib/dtoa.c:506: undefined reference to `__aeabi_dcmpgt'
C:\msys\1.0\home\yagarto\newlib-build\arm-none-eabi\newlib\libc\stdlib/../../../../../newlib-1.20.0/newlib/libc/stdlib/dtoa.c:506: undefined reference to `__aeabi_dsub'
C:\msys\1.0\home\yagarto\newlib-build\arm-none-eabi\newlib\libc\stdlib/../../../../../newlib-1.20.0/newlib/libc/stdlib/dtoa.c:506: undefined reference to `__aeabi_dcmplt'
C:\msys\1.0\home\yagarto\newlib-build\arm-none-eabi\newlib\libc\stdlib/../../../../../newlib-1.20.0/newlib/libc/stdlib/dtoa.c:510: undefined reference to `__aeabi_dmul'
C:\msys\1.0\home\yagarto\newlib-build\arm-none-eabi\newlib\libc\stdlib/../../../../../newlib-1.20.0/newlib/libc/stdlib/dtoa.c:511: undefined reference to `__aeabi_dmul'
C:\msys\1.0\home\yagarto\newlib-build\arm-none-eabi\newlib\libc\stdlib/../../../../../newlib-1.20.0/newlib/libc/stdlib/dtoa.c:501: undefined reference to `__aeabi_d2iz'
C:\msys\1.0\home\yagarto\newlib-build\arm-none-eabi\newlib\libc\stdlib/../../../../../newlib-1.20.0/newlib/libc/stdlib/dtoa.c:502: undefined reference to `__aeabi_i2d'
C:\msys\1.0\home\yagarto\newlib-build\arm-none-eabi\newlib\libc\stdlib/../../../../../newlib-1.20.0/newlib/libc/stdlib/dtoa.c:502: undefined reference to `__aeabi_dsub'
C:\msys\1.0\home\yagarto\newlib-build\arm-none-eabi\newlib\libc\stdlib/../../../../../newlib-1.20.0/newlib/libc/stdlib/dtoa.c:504: undefined reference to `__aeabi_dcmplt'
C:\msys\1.0\home\yagarto\newlib-build\arm-none-eabi\newlib\libc\stdlib/../../../../../newlib-1.20.0/newlib/libc/stdlib/dtoa.c:480: undefined reference to `__aeabi_i2d'
C:\msys\1.0\home\yagarto\newlib-build\arm-none-eabi\newlib\libc\stdlib/../../../../../newlib-1.20.0/newlib/libc/stdlib/dtoa.c:480: undefined reference to `__aeabi_dmul'
C:\msys\1.0\home\yagarto\newlib-build\arm-none-eabi\newlib\libc\stdlib/../../../../../newlib-1.20.0/newlib/libc/stdlib/dtoa.c:480: undefined reference to `__aeabi_dadd'
C:\msys\1.0\home\yagarto\newlib-build\arm-none-eabi\newlib\libc\stdlib/../../../../../newlib-1.20.0/newlib/libc/stdlib/dtoa.c:485: undefined reference to `__aeabi_dsub'
C:\msys\1.0\home\yagarto\newlib-build\arm-none-eabi\newlib\libc\stdlib/../../../../../newlib-1.20.0/newlib/libc/stdlib/dtoa.c:486: undefined reference to `__aeabi_dcmpgt'
C:\msys\1.0\home\yagarto\newlib-build\arm-none-eabi\newlib\libc\stdlib/../../../../../newlib-1.20.0/newlib/libc/stdlib/dtoa.c:488: undefined reference to `__aeabi_dcmplt'
C:\msys\1.0\home\yagarto\newlib-build\arm-none-eabi\newlib\libc\stdlib/../../../../../newlib-1.20.0/newlib/libc/stdlib/dtoa.c:463: undefined reference to `__aeabi_dmul'
C:\msys\1.0\home\yagarto\newlib-build\arm-none-eabi\newlib\libc\stdlib/../../../../../newlib-1.20.0/newlib/libc/stdlib/dtoa.c:468: undefined reference to `__aeabi_dmul'
C:\msys\1.0\home\yagarto\newlib-build\arm-none-eabi\newlib\libc\stdlib/../../../../../newlib-1.20.0/newlib/libc/stdlib/dtoa.c:518: undefined reference to `__aeabi_dmul'
C:\msys\1.0\home\yagarto\newlib-build\arm-none-eabi\newlib\libc\stdlib/../../../../../newlib-1.20.0/newlib/libc/stdlib/dtoa.c:521: undefined reference to `__aeabi_d2iz'
C:\msys\1.0\home\yagarto\newlib-build\arm-none-eabi\newlib\libc\stdlib/../../../../../newlib-1.20.0/newlib/libc/stdlib/dtoa.c:522: undefined reference to `__aeabi_i2d'
C:\msys\1.0\home\yagarto\newlib-build\arm-none-eabi\newlib\libc\stdlib/../../../../../newlib-1.20.0/newlib/libc/stdlib/dtoa.c:522: undefined reference to `__aeabi_dsub'
C:\msys\1.0\home\yagarto\newlib-build\arm-none-eabi\newlib\libc\stdlib/../../../../../newlib-1.20.0/newlib/libc/stdlib/dtoa.c:519: undefined reference to `__aeabi_dmul'
C:\msys\1.0\home\yagarto\newlib-build\arm-none-eabi\newlib\libc\stdlib/../../../../../newlib-1.20.0/newlib/libc/stdlib/dtoa.c:521: undefined reference to `__aeabi_d2iz'
C:\msys\1.0\home\yagarto\newlib-build\arm-none-eabi\newlib\libc\stdlib/../../../../../newlib-1.20.0/newlib/libc/stdlib/dtoa.c:522: undefined reference to `__aeabi_i2d'
C:\msys\1.0\home\yagarto\newlib-build\arm-none-eabi\newlib\libc\stdlib/../../../../../newlib-1.20.0/newlib/libc/stdlib/dtoa.c:522: undefined reference to `__aeabi_dsub'
C:\msys\1.0\home\yagarto\newlib-build\arm-none-eabi\newlib\libc\stdlib/../../../../../newlib-1.20.0/newlib/libc/stdlib/dtoa.c:526: undefined reference to `__aeabi_dadd'
C:\msys\1.0\home\yagarto\newlib-build\arm-none-eabi\newlib\libc\stdlib/../../../../../newlib-1.20.0/newlib/libc/stdlib/dtoa.c:526: undefined reference to `__aeabi_dcmplt'
C:\msys\1.0\home\yagarto\newlib-build\arm-none-eabi\newlib\libc\stdlib/../../../../../newlib-1.20.0/newlib/libc/stdlib/dtoa.c:556: undefined reference to `__aeabi_dmul'
C:\msys\1.0\home\yagarto\newlib-build\arm-none-eabi\newlib\libc\stdlib/../../../../../newlib-1.20.0/newlib/libc/stdlib/dtoa.c:556: undefined reference to `__aeabi_dcmpge'
C:\msys\1.0\home\yagarto\newlib-build\arm-none-eabi\newlib\libc\stdlib/../../../../../newlib-1.20.0/newlib/libc/stdlib/dtoa.c:477: undefined reference to `__aeabi_dmul'
C:\msys\1.0\home\yagarto\newlib-build\arm-none-eabi\newlib\libc\stdlib/../../../../../newlib-1.20.0/newlib/libc/stdlib/dtoa.c:480: undefined reference to `__aeabi_i2d'
C:\msys\1.0\home\yagarto\newlib-build\arm-none-eabi\newlib\libc\stdlib/../../../../../newlib-1.20.0/newlib/libc/stdlib/dtoa.c:480: undefined reference to `__aeabi_dmul'
C:\msys\1.0\home\yagarto\newlib-build\arm-none-eabi\newlib\libc\stdlib/../../../../../newlib-1.20.0/newlib/libc/stdlib/dtoa.c:480: undefined reference to `__aeabi_dadd'
C:\msys\1.0\home\yagarto\newlib-build\arm-none-eabi\newlib\libc\stdlib/../../../../../newlib-1.20.0/newlib/libc/stdlib/dtoa.c:528: undefined reference to `__aeabi_dsub'
C:\msys\1.0\home\yagarto\newlib-build\arm-none-eabi\newlib\libc\stdlib/../../../../../newlib-1.20.0/newlib/libc/stdlib/dtoa.c:528: undefined reference to `__aeabi_dcmpgt'
libg.a(lib_a-mprec.o): In function `__ratio':
C:\msys\1.0\home\yagarto\newlib-build\arm-none-eabi\newlib\libc\stdlib/../../../../../newlib-1.20.0/newlib/libc/stdlib/mprec.c:950: undefined reference to `__aeabi_ddiv'
libg.a(lib_a-mprec.o): In function `_mprec_log10':
C:\msys\1.0\home\yagarto\newlib-build\arm-none-eabi\newlib\libc\stdlib/../../../../../newlib-1.20.0/newlib/libc/stdlib/mprec.c:987: undefined reference to `__aeabi_dmul'
libg.a(lib_a-sbrkr.o): In function `_sbrk_r':
C:\msys\1.0\home\yagarto\newlib-build\arm-none-eabi\newlib\libc\reent/../../../../../newlib-1.20.0/newlib/libc/reent/sbrkr.c:58: undefined reference to `_sbrk'
libg.a(lib_a-writer.o): In function `_write_r':
C:\msys\1.0\home\yagarto\newlib-build\arm-none-eabi\newlib\libc\reent/../../../../../newlib-1.20.0/newlib/libc/reent/writer.c:58: undefined reference to `_write'
libg.a(lib_a-closer.o): In function `_close_r':
C:\msys\1.0\home\yagarto\newlib-build\arm-none-eabi\newlib\libc\reent/../../../../../newlib-1.20.0/newlib/libc/reent/closer.c:53: undefined reference to `_close'
libg.a(lib_a-fstatr.o): In function `_fstat_r':
C:\msys\1.0\home\yagarto\newlib-build\arm-none-eabi\newlib\libc\reent/../../../../../newlib-1.20.0/newlib/libc/reent/fstatr.c:62: undefined reference to `_fstat'
libg.a(lib_a-isattyr.o): In function `_isatty_r':
C:\msys\1.0\home\yagarto\newlib-build\arm-none-eabi\newlib\libc\reent/../../../../../newlib-1.20.0/newlib/libc/reent/isattyr.c:58: undefined reference to `_isatty'
libg.a(lib_a-lseekr.o): In function `_lseek_r':
C:\msys\1.0\home\yagarto\newlib-build\arm-none-eabi\newlib\libc\reent/../../../../../newlib-1.20.0/newlib/libc/reent/lseekr.c:58: undefined reference to `_lseek'
libg.a(lib_a-readr.o): In function `_read_r':
C:\msys\1.0\home\yagarto\newlib-build\arm-none-eabi\newlib\libc\reent/../../../../../newlib-1.20.0/newlib/libc/reent/readr.c:58: undefined reference to `_read'
make: *** [main.out] Error 1


I think, I should use Newlib. Which one seems to be installed with yagarto. But I can't find none of this files, like  dtoa.c or readr.c ...

I read this problem could be solved with a syscalls, so I used one from Michael Fischer, but I didn't succeed.


Hope someone can help me...

Thanks.

LubOlimex

Hey Vince,

The GNU toolchain documentation is a good source of information on the makefiles.

Additionally have you stumbled upon the OLIMEX ODS? https://www.olimex.com/Products/ARM/JTAG/_resources/OpenOCD/

Best regards,
Lub/OLIMEX
Technical support and documentation manager at Olimex

gscheben

Vince,
did you ever resolve this issue?
Can you post a solution?

I tried adding the All the OlimexODS "include" folder to the project settings, but the compiler still can't find a reference to "printf" including <stdio.h>.
When I used a previous version of Eclipse/yargarto toolchain for the LPC2478 it was able to resolve <stdio.h> references, but after looking at the makefile it's not apparent how this is done. The "template" makefile for the OlimexODS examples are far more cryptic.

A simple example on GitHub seems like a good reference for remapping printf to the serial port:

https://github.com/bjornfor/stm32-test/tree/master/STM32F0xx_StdPeriph_Lib_V1.0.0/Project/STM32F0xx_StdPeriph_Examples/USART/Printf

but the author doesn't reference how how resolve any "undefined reference to printf".

Vince

No, I didn't solve this issue. I was a bit busy....  :-[

I'll look at it seriously the next week. I'll let you know whether I find out something.