0

I used this tutorial to setup all of my software: http://www.angstromsandalgorithms.com/free-eclipse-arm-gcc-openocd-toolchain-for-windows-part-3-eclipse-ide/

I'm using an STM32F405RGT6 arm. I'm also on windows. I have tried adding -lm everywhere in the makefile and havn't had anything work. Basically I just want to be able to #include "math.h" so I can use the math functions...I'm also assuming placing -lm in the right place is all I need to do from all the google searches I've done...I'm also thinking my makefile might be not be linking things correctly and/or i might not have things linked properly in eclipse.

Here is 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/../../ # Objects built from C source files C_OBJECTS = $(OBJ)/main.o C_OBJECTS += $(OBJ)/system_stm32f4xx.o C_OBJECTS += $(OBJ)/stm32f4xx_gpio.o C_OBJECTS += $(OBJ)/stm32f4xx_rcc.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) 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)/stm32f4xx_gpio.o $(LIBRARYSRC)/stm32f4xx_gpio.c $(CC) $(CFLAGS) -o $(OBJ)/stm32f4xx_rcc.o $(LIBRARYSRC)/stm32f4xx_rcc.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
itb
  • 63
  • 6
  • look at this answer http://stackoverflow.com/questions/10059146/gcc-libm-not-working/10059154#10059154 and this http://stackoverflow.com/a/19372412/4493674 – Cristian Olaru Jan 30 '15 at 03:05
  • I've seen this but I seem to be unable to pick the right place to put -lm...if that's all I need to do. I'm hoping someone can pick out exactly where it should go if that's my only problem. – itb Jan 30 '15 at 03:08
  • here is saying perfectly where to put -lm http://stackoverflow.com/a/10409061/4493674 – Cristian Olaru Jan 30 '15 at 03:15
  • again more links http://stackoverflow.com/questions/1033898/why-do-you-have-to-link-the-math-library-in-c http://stackoverflow.com/a/5248951/4493674 http://www.eclipse.org/forums/index.php?t=msg&th=68204/ – Cristian Olaru Jan 30 '15 at 03:17
  • let me explain further I've seen most of those links I'm literally not getting it and the -lm is not working for me when I attempt to place where I think someone is trying to indicate for me to place it. I am wondering if it has something to do with linking that's why I added a link in the top of my page to show how I linked in the arm gcc library. Although I'm really unsure about everything since this is my first time with arm and eclipse lol. I'm left with just asking where to place this in my makefile exactly that's why I've included it.... – itb Jan 30 '15 at 03:21
  • in Eclipse, go to Project > Properties > C/C++ Build > Settings > GCC C Linker > Miscellaneous > add "-lm" to the "Linker Flags" text field. That way it is properly linked to the project. – Cristian Olaru Jan 30 '15 at 03:29
  • I've tried this before but it doesn't work for me the way I have it set up using the link above. Reason it doesn't is I don't have a GCC C Linker option. When I tried to configured it to have this my makefile wasn't working at all, so I had to go back to the makefile I was given since I'm not exactly sure what's required yet to make a competent makefile in the first place. The makefile I'm using is from the olimexods examples. – itb Jan 30 '15 at 03:38
  • aham, when I've searched your problem for openOCD toolchain I found this link http://www.triplespark.net/elec/pdev/arm/stm32.html in the page search for "math" – Cristian Olaru Jan 30 '15 at 03:45
  • Yes that's the one that made me think I'm not linking things properly but I still havn't gotten it to work. It also made me wonder if I don't need to download arm CMSIS to get at the dsp functions and all these options might allready be in arm gcc? – itb Jan 30 '15 at 03:49
  • maybe this would help you http://clalance.blogspot.ro/2014_01_01_archive.html search for "-lm" till you find the makefile (3rd search) see where the flags are and keep posting when you solve the problem. – Cristian Olaru Jan 30 '15 at 04:06
  • working makefile files https://github.com/una1veritas/ARMWork/blob/master/stm32f4-float-math_test/Makefile https://github.com/devthrash/STM32F4-examples/blob/master/Makefile – Cristian Olaru Jan 30 '15 at 04:35
  • links aren't helping me...I've allready spent days googling all the keywords you might find in my post. – itb Jan 31 '15 at 01:48
  • did you solve the problem? – Cristian Olaru Feb 02 '15 at 13:16

0 Answers0