Forum: Compiler & IDEs Makefile Problem


Announcement: there is an English version of this forum on EmbDev.net. Posts you create there will be displayed on Mikrocontroller.net and EmbDev.net.
von Tobi (Gast)


Bewertung
0 lesenswert
nicht lesenswert
Hallo,
ich verusche eine Projekt für ein STM32F407 mit einen Makefile zu 
kompileren. Leider gibt es einen ERROR beim linken mit folgender 
Meldung:
COLLECT_GCC_OPTIONS='-g' '-D' 'inline=' '-mthumb' '-mcpu=cortex-m4' '-O1' '-T' '/home/tobias/STM32-Toolchain/STM32F4xx_DSP_StdPeriph_Lib/Project/STM32F4xx_StdPeriph_Templates/TrueSTUDIO/STM32F40_41xxx/STM32F417IG_FLASH.ld' '-D' 'PACK_STRUCT_END=__attribute((packed))' '-Wno-main' '-D' 'ALIGN_STRUCT_END=__attribute((aligned(4)))' '-ffunction-sections' '-fdata-sections' '-I' './' '-I' '/home/tobias/STM32-Toolchain/STM32F4xx_DSP_StdPeriph_Lib/Libraries/CMSIS/Include/' '-I' '/home/tobias/STM32-Toolchain/STM32F4xx_DSP_StdPeriph_Lib/Libraries/CMSIS/Device/ST/STM32F4xx/Include' '-I' '/home/tobias/STM32-Toolchain/STM32F4xx_DSP_StdPeriph_Lib/Libraries/CMSIS/Include' '-I' '/home/tobias/STM32-Toolchain/STM32F4xx_DSP_StdPeriph_Lib/Libraries/STM32F4xx_StdPeriph_Driver/inc' '-I' '/home/tobias/STM32-Toolchain/STM32F4xx_DSP_StdPeriph_Lib/Utilities/STM32_EVAL/STM320518_EVAL' '-I' '/home/tobias/STM32-Toolchain/STM32F4xx_DSP_StdPeriph_Lib/Utilities/STM32_EVAL/Common' '-I' '/home/tobias/STM32-Toolchain/STM32F4xx_DSP_StdPeriph_Lib/Project/STM32F0xx_StdPeriph_Templates' '-D' 'STM32F4XX' '-D' 'GCC_ARMCM3' '-D' 'USE_STDPERIPH_DRIVER' '-D' 'HSE_VALUE=8000000' '-D' 'USE_USB_OTG_FS' '-D' 'STM32F40_41xxx' '-Wno-attributes' '-v' '-c' '-o' 'obj/system_stm32f4xx.o'
/home/tobias/bin/gcc-arm-none-eabi-4_7-2012q4/bin/../lib/gcc/arm-none-eabi/4.7.3/../../../../arm-none-eabi/lib/armv7e-m/libg.a(lib_a-init.o): In function `__libc_init_array':
init.c:(.text.__libc_init_array+0x40): undefined reference to `_init'
collect2: error: ld returned 1 exit status

Könnt ihr mir sagen was ich falsch mache?

Das Makefile sieht wie folgt aus:
SHELL = sh

PROJ_NAME=stm32-iir

STLIB_PATH = /home/tobias/STM32-Toolchain/STM32F4xx_DSP_StdPeriph_Lib
LDSCRIPT = $(STLIB_PATH)/Project/STM32F4xx_StdPeriph_Templates/TrueSTUDIO/STM32F40_41xxx/STM32F417IG_FLASH.ld
LDFLAGS = -T$(LDSCRIPT)

#|---------------------------------------------------------------------------------------|
#| Speficy project source files                                                          |
#|---------------------------------------------------------------------------------------|
PROJ_FILES= \
main.c \
stm32f4xx_conf.h \
$(STLIB_PATH)/Libraries/STM32F4xx_StdPeriph_Driver/src/misc.c \
$(STLIB_PATH)/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_adc.c \
$(STLIB_PATH)/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_can.c \
$(STLIB_PATH)/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_crc.c \
$(STLIB_PATH)/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_cryp.c \
$(STLIB_PATH)/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_cryp_aes.c \
$(STLIB_PATH)/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_cryp_des.c \
$(STLIB_PATH)/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_cryp_tdes.c \
$(STLIB_PATH)/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_dac.c \
$(STLIB_PATH)/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_dbgmcu.c \
$(STLIB_PATH)/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_dcmi.c \
$(STLIB_PATH)/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_dma.c \
$(STLIB_PATH)/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_dma2d.c \
$(STLIB_PATH)/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_exti.c \
$(STLIB_PATH)/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_flash.c \
$(STLIB_PATH)/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_flash_ramfunc.c \
$(STLIB_PATH)/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_fsmc.c \
$(STLIB_PATH)/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_gpio.c \
$(STLIB_PATH)/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_hash.c \
$(STLIB_PATH)/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_hash_md5.c \
$(STLIB_PATH)/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_hash_sha1.c \
$(STLIB_PATH)/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_i2c.c \
$(STLIB_PATH)/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_iwdg.c \
$(STLIB_PATH)/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_ltdc.c \
$(STLIB_PATH)/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_pwr.c \
$(STLIB_PATH)/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_rcc.c \
$(STLIB_PATH)/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_rng.c \
$(STLIB_PATH)/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_rtc.c \
$(STLIB_PATH)/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_sai.c \
$(STLIB_PATH)/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_sdio.c \
$(STLIB_PATH)/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_spi.c \
$(STLIB_PATH)/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_syscfg.c \
$(STLIB_PATH)/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_tim.c \
$(STLIB_PATH)/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_usart.c \
$(STLIB_PATH)/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_wwdg.c \
$(STLIB_PATH)/Libraries/CMSIS/Include/core_cmSimd.h \
$(STLIB_PATH)/Libraries/CMSIS/Include/core_cmFunc.h \
$(STLIB_PATH)/Libraries/CMSIS/Include/core_cmInstr.h \
$(STLIB_PATH)/Libraries/CMSIS/Device/ST/STM32F4xx/Source/Templates/TrueSTUDIO/startup_stm32f40xx.s \
$(STLIB_PATH)/Libraries/CMSIS/Device/ST/STM32F4xx/Source/Templates/system_stm32f4xx.c


#|---------------------------------------------------------------------------------------|
#| Compiler binaries                                                                     |
#|---------------------------------------------------------------------------------------|
CC = arm-none-eabi-gcc
LN = arm-none-eabi-gcc
OC = arm-none-eabi-objcopy
OD = arm-none-eabi-objdump
AS = arm-none-eabi-as
SZ = arm-none-eabi-size


#|---------------------------------------------------------------------------------------|
#| Extract file names                                                                    |
#|---------------------------------------------------------------------------------------|
PROJ_ASRCS  = $(filter %.s,$(foreach file,$(PROJ_FILES),$(notdir $(file))))
PROJ_CSRCS  = $(filter %.c,$(foreach file,$(PROJ_FILES),$(notdir $(file))))
PROJ_CHDRS  = $(filter %.h,$(foreach file,$(PROJ_FILES),$(notdir $(file))))
PROJ_CCMPL  = $(patsubst %.c,%.cpl,$(PROJ_CSRCS))
PROJ_ACMPL  = $(patsubst %.s,%.cpl,$(PROJ_ASRCS))


#|---------------------------------------------------------------------------------------|
#| Set important path variables                                                          |
#|---------------------------------------------------------------------------------------|
VPATH    = $(foreach path,$(sort $(foreach file,$(PROJ_FILES),$(dir $(file)))) $(subst \,/,$(OBJ_PATH)),$(path) :)
OBJ_PATH = obj
BIN_PATH = bin
INC_PATH = $(patsubst %,-I%,$(sort $(foreach file,$(filter %.h,$(PROJ_FILES)),$(dir $(file)))))
INC_PATH += -I$(STLIB_PATH)/Libraries/CMSIS/Device/ST/STM32F4xx/Include \
    -I$(STLIB_PATH)/Libraries/CMSIS/Include \
    -I$(STLIB_PATH)/Libraries/STM32F4xx_StdPeriph_Driver/inc \
    -I$(STLIB_PATH)/Utilities/STM32_EVAL/STM320518_EVAL \
    -I$(STLIB_PATH)/Utilities/STM32_EVAL/Common \
    -I$(STLIB_PATH)/Project/STM32F0xx_StdPeriph_Templates


#|---------------------------------------------------------------------------------------|
#| Options for compiler binaries                                                         |
#|---------------------------------------------------------------------------------------|
CFLAGS   = -g -D inline= -mthumb -mcpu=cortex-m4 -O1 $(LDFLAGS)
CFLAGS  += -D PACK_STRUCT_END=__attribute\(\(packed\)\) -Wno-main
CFLAGS  += -D ALIGN_STRUCT_END=__attribute\(\(aligned\(4\)\)\) 
CFLAGS  += -ffunction-sections -fdata-sections $(INC_PATH) -D STM32F4XX -D GCC_ARMCM3
CFLAGS  += -D USE_STDPERIPH_DRIVER -D HSE_VALUE=8000000 -D USE_USB_OTG_FS -D STM32F40_41xxx
CFLAGS  += -Wa,-adhlns="$(OBJ_PATH)/$(subst .o,.lst,$@)" -Wno-attributes
LFLAGS   = -nostartfiles -Xlinker -M -Xlinker -Map=$(BIN_PATH)/$(PROJ_NAME).map
LFLAGS  += $(LIB_PATH) -Xlinker --gc-sections
OFLAGS   = -O srec
ODFLAGS  = -x
SZFLAGS  = -B -d


#|---------------------------------------------------------------------------------------|
#| Specify library files                                                                 |
#|---------------------------------------------------------------------------------------|
LIBS = 


#|---------------------------------------------------------------------------------------|
#| Define targets                                                                        |
#|---------------------------------------------------------------------------------------|
AOBJS = $(patsubst %.s,%.o,$(PROJ_ASRCS))
COBJS = $(patsubst %.c,%.o,$(PROJ_CSRCS))



#|---------------------------------------------------------------------------------------|
#| Make ALL                                                                              |
#|---------------------------------------------------------------------------------------|
all : $(BIN_PATH)/$(PROJ_NAME).srec


$(BIN_PATH)/$(PROJ_NAME).srec : $(BIN_PATH)/$(PROJ_NAME).elf
  @$(OC) $< $(OFLAGS) $@
  @$(OD) $(ODFLAGS) $< > $(BIN_PATH)/$(PROJ_NAME).map
  @echo +++ Summary of memory consumption:
  @$(SZ) $(SZFLAGS) $<
  @echo +++ Build complete [$(notdir $@)]

$(BIN_PATH)/$(PROJ_NAME).elf : $(AOBJS) $(COBJS) 
  @echo +++ Linking [$(notdir $@)]
  @$(LN) $(CFLAGS) -o $@ $(patsubst %.o,$(OBJ_PATH)/%.o,$(^F)) $(LIBS) $(LFLAGS)


#|---------------------------------------------------------------------------------------|
#| Compile and assemble                                                                  |
#|---------------------------------------------------------------------------------------|
$(AOBJS): %.o: %.s $(PROJ_CHDRS)
  @echo +++ Assembling [$(notdir $<)]
  @$(AS) $(AFLAGS) $< -o $(OBJ_PATH)/$(@F)

$(COBJS): %.o: %.c $(PROJ_CHDRS)
  @echo +++ Compiling [$(notdir $<)]
  @$(CC) $(CFLAGS) -v -c $< -o $(OBJ_PATH)/$(@F)


#|---------------------------------------------------------------------------------------|
#| Make CLEAN                                                                            |
#|---------------------------------------------------------------------------------------|
clean : 
  @echo +++ Cleaning build environment
  @rm -f $(foreach file,$(AOBJS),$(OBJ_PATH)/$(file))
  @rm -f $(foreach file,$(COBJS),$(OBJ_PATH)/$(file))
  @rm -f $(patsubst %.o,%.lst,$(foreach file,$(COBJS),$(OBJ_PATH)/$(file)))
  @rm -f $(BIN_PATH)/$(PROJ_NAME).elf $(BIN_PATH)/$(PROJ_NAME).map
  @rm -f $(BIN_PATH)/$(PROJ_NAME).srec
  @echo +++ Clean complete

von Lukas K. (carrotindustries)


Bewertung
0 lesenswert
nicht lesenswert
Tobi schrieb:
> -nostartfiles

Mach das mal weg.

von Tobi (Gast)


Bewertung
0 lesenswert
nicht lesenswert
Danke hat geklapt

Antwort schreiben

Die Angabe einer E-Mail-Adresse ist freiwillig. Wenn Sie automatisch per E-Mail über Antworten auf Ihren Beitrag informiert werden möchten, melden Sie sich bitte an.

Wichtige Regeln - erst lesen, dann posten!

  • Groß- und Kleinschreibung verwenden
  • Längeren Sourcecode nicht im Text einfügen, sondern als Dateianhang

Formatierung (mehr Informationen...)

  • [c]C-Code[/c]
  • [avrasm]AVR-Assembler-Code[/avrasm]
  • [code]Code in anderen Sprachen, ASCII-Zeichnungen[/code]
  • [math]Formel in LaTeX-Syntax[/math]
  • [[Titel]] - Link zu Artikel
  • Verweis auf anderen Beitrag einfügen: Rechtsklick auf Beitragstitel,
    "Adresse kopieren", und in den Text einfügen




Bild automatisch verkleinern, falls nötig
Bitte das JPG-Format nur für Fotos und Scans verwenden!
Zeichnungen und Screenshots im PNG- oder
GIF-Format hochladen. Siehe Bildformate.
Hinweis: der ursprüngliche Beitrag ist mehr als 6 Monate alt.
Bitte hier nur auf die ursprüngliche Frage antworten,
für neue Fragen einen neuen Beitrag erstellen.

Mit dem Abschicken bestätigst du, die Nutzungsbedingungen anzuerkennen.