Forum: Compiler & IDEs Makefile Problem


von Tobi (Gast)


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:
1
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'
2
/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':
3
init.c:(.text.__libc_init_array+0x40): undefined reference to `_init'
4
collect2: error: ld returned 1 exit status

Könnt ihr mir sagen was ich falsch mache?

Das Makefile sieht wie folgt aus:
1
SHELL = sh
2
3
PROJ_NAME=stm32-iir
4
5
STLIB_PATH = /home/tobias/STM32-Toolchain/STM32F4xx_DSP_StdPeriph_Lib
6
LDSCRIPT = $(STLIB_PATH)/Project/STM32F4xx_StdPeriph_Templates/TrueSTUDIO/STM32F40_41xxx/STM32F417IG_FLASH.ld
7
LDFLAGS = -T$(LDSCRIPT)
8
9
#|---------------------------------------------------------------------------------------|
10
#| Speficy project source files                                                          |
11
#|---------------------------------------------------------------------------------------|
12
PROJ_FILES= \
13
main.c \
14
stm32f4xx_conf.h \
15
$(STLIB_PATH)/Libraries/STM32F4xx_StdPeriph_Driver/src/misc.c \
16
$(STLIB_PATH)/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_adc.c \
17
$(STLIB_PATH)/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_can.c \
18
$(STLIB_PATH)/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_crc.c \
19
$(STLIB_PATH)/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_cryp.c \
20
$(STLIB_PATH)/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_cryp_aes.c \
21
$(STLIB_PATH)/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_cryp_des.c \
22
$(STLIB_PATH)/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_cryp_tdes.c \
23
$(STLIB_PATH)/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_dac.c \
24
$(STLIB_PATH)/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_dbgmcu.c \
25
$(STLIB_PATH)/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_dcmi.c \
26
$(STLIB_PATH)/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_dma.c \
27
$(STLIB_PATH)/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_dma2d.c \
28
$(STLIB_PATH)/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_exti.c \
29
$(STLIB_PATH)/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_flash.c \
30
$(STLIB_PATH)/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_flash_ramfunc.c \
31
$(STLIB_PATH)/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_fsmc.c \
32
$(STLIB_PATH)/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_gpio.c \
33
$(STLIB_PATH)/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_hash.c \
34
$(STLIB_PATH)/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_hash_md5.c \
35
$(STLIB_PATH)/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_hash_sha1.c \
36
$(STLIB_PATH)/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_i2c.c \
37
$(STLIB_PATH)/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_iwdg.c \
38
$(STLIB_PATH)/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_ltdc.c \
39
$(STLIB_PATH)/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_pwr.c \
40
$(STLIB_PATH)/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_rcc.c \
41
$(STLIB_PATH)/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_rng.c \
42
$(STLIB_PATH)/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_rtc.c \
43
$(STLIB_PATH)/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_sai.c \
44
$(STLIB_PATH)/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_sdio.c \
45
$(STLIB_PATH)/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_spi.c \
46
$(STLIB_PATH)/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_syscfg.c \
47
$(STLIB_PATH)/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_tim.c \
48
$(STLIB_PATH)/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_usart.c \
49
$(STLIB_PATH)/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_wwdg.c \
50
$(STLIB_PATH)/Libraries/CMSIS/Include/core_cmSimd.h \
51
$(STLIB_PATH)/Libraries/CMSIS/Include/core_cmFunc.h \
52
$(STLIB_PATH)/Libraries/CMSIS/Include/core_cmInstr.h \
53
$(STLIB_PATH)/Libraries/CMSIS/Device/ST/STM32F4xx/Source/Templates/TrueSTUDIO/startup_stm32f40xx.s \
54
$(STLIB_PATH)/Libraries/CMSIS/Device/ST/STM32F4xx/Source/Templates/system_stm32f4xx.c
55
56
57
#|---------------------------------------------------------------------------------------|
58
#| Compiler binaries                                                                     |
59
#|---------------------------------------------------------------------------------------|
60
CC = arm-none-eabi-gcc
61
LN = arm-none-eabi-gcc
62
OC = arm-none-eabi-objcopy
63
OD = arm-none-eabi-objdump
64
AS = arm-none-eabi-as
65
SZ = arm-none-eabi-size
66
67
68
#|---------------------------------------------------------------------------------------|
69
#| Extract file names                                                                    |
70
#|---------------------------------------------------------------------------------------|
71
PROJ_ASRCS  = $(filter %.s,$(foreach file,$(PROJ_FILES),$(notdir $(file))))
72
PROJ_CSRCS  = $(filter %.c,$(foreach file,$(PROJ_FILES),$(notdir $(file))))
73
PROJ_CHDRS  = $(filter %.h,$(foreach file,$(PROJ_FILES),$(notdir $(file))))
74
PROJ_CCMPL  = $(patsubst %.c,%.cpl,$(PROJ_CSRCS))
75
PROJ_ACMPL  = $(patsubst %.s,%.cpl,$(PROJ_ASRCS))
76
77
78
#|---------------------------------------------------------------------------------------|
79
#| Set important path variables                                                          |
80
#|---------------------------------------------------------------------------------------|
81
VPATH    = $(foreach path,$(sort $(foreach file,$(PROJ_FILES),$(dir $(file)))) $(subst \,/,$(OBJ_PATH)),$(path) :)
82
OBJ_PATH = obj
83
BIN_PATH = bin
84
INC_PATH = $(patsubst %,-I%,$(sort $(foreach file,$(filter %.h,$(PROJ_FILES)),$(dir $(file)))))
85
INC_PATH += -I$(STLIB_PATH)/Libraries/CMSIS/Device/ST/STM32F4xx/Include \
86
    -I$(STLIB_PATH)/Libraries/CMSIS/Include \
87
    -I$(STLIB_PATH)/Libraries/STM32F4xx_StdPeriph_Driver/inc \
88
    -I$(STLIB_PATH)/Utilities/STM32_EVAL/STM320518_EVAL \
89
    -I$(STLIB_PATH)/Utilities/STM32_EVAL/Common \
90
    -I$(STLIB_PATH)/Project/STM32F0xx_StdPeriph_Templates
91
92
93
#|---------------------------------------------------------------------------------------|
94
#| Options for compiler binaries                                                         |
95
#|---------------------------------------------------------------------------------------|
96
CFLAGS   = -g -D inline= -mthumb -mcpu=cortex-m4 -O1 $(LDFLAGS)
97
CFLAGS  += -D PACK_STRUCT_END=__attribute\(\(packed\)\) -Wno-main
98
CFLAGS  += -D ALIGN_STRUCT_END=__attribute\(\(aligned\(4\)\)\) 
99
CFLAGS  += -ffunction-sections -fdata-sections $(INC_PATH) -D STM32F4XX -D GCC_ARMCM3
100
CFLAGS  += -D USE_STDPERIPH_DRIVER -D HSE_VALUE=8000000 -D USE_USB_OTG_FS -D STM32F40_41xxx
101
CFLAGS  += -Wa,-adhlns="$(OBJ_PATH)/$(subst .o,.lst,$@)" -Wno-attributes
102
LFLAGS   = -nostartfiles -Xlinker -M -Xlinker -Map=$(BIN_PATH)/$(PROJ_NAME).map
103
LFLAGS  += $(LIB_PATH) -Xlinker --gc-sections
104
OFLAGS   = -O srec
105
ODFLAGS  = -x
106
SZFLAGS  = -B -d
107
108
109
#|---------------------------------------------------------------------------------------|
110
#| Specify library files                                                                 |
111
#|---------------------------------------------------------------------------------------|
112
LIBS = 
113
114
115
#|---------------------------------------------------------------------------------------|
116
#| Define targets                                                                        |
117
#|---------------------------------------------------------------------------------------|
118
AOBJS = $(patsubst %.s,%.o,$(PROJ_ASRCS))
119
COBJS = $(patsubst %.c,%.o,$(PROJ_CSRCS))
120
121
122
123
#|---------------------------------------------------------------------------------------|
124
#| Make ALL                                                                              |
125
#|---------------------------------------------------------------------------------------|
126
all : $(BIN_PATH)/$(PROJ_NAME).srec
127
128
129
$(BIN_PATH)/$(PROJ_NAME).srec : $(BIN_PATH)/$(PROJ_NAME).elf
130
  @$(OC) $< $(OFLAGS) $@
131
  @$(OD) $(ODFLAGS) $< > $(BIN_PATH)/$(PROJ_NAME).map
132
  @echo +++ Summary of memory consumption:
133
  @$(SZ) $(SZFLAGS) $<
134
  @echo +++ Build complete [$(notdir $@)]
135
136
$(BIN_PATH)/$(PROJ_NAME).elf : $(AOBJS) $(COBJS) 
137
  @echo +++ Linking [$(notdir $@)]
138
  @$(LN) $(CFLAGS) -o $@ $(patsubst %.o,$(OBJ_PATH)/%.o,$(^F)) $(LIBS) $(LFLAGS)
139
140
141
#|---------------------------------------------------------------------------------------|
142
#| Compile and assemble                                                                  |
143
#|---------------------------------------------------------------------------------------|
144
$(AOBJS): %.o: %.s $(PROJ_CHDRS)
145
  @echo +++ Assembling [$(notdir $<)]
146
  @$(AS) $(AFLAGS) $< -o $(OBJ_PATH)/$(@F)
147
148
$(COBJS): %.o: %.c $(PROJ_CHDRS)
149
  @echo +++ Compiling [$(notdir $<)]
150
  @$(CC) $(CFLAGS) -v -c $< -o $(OBJ_PATH)/$(@F)
151
152
153
#|---------------------------------------------------------------------------------------|
154
#| Make CLEAN                                                                            |
155
#|---------------------------------------------------------------------------------------|
156
clean : 
157
  @echo +++ Cleaning build environment
158
  @rm -f $(foreach file,$(AOBJS),$(OBJ_PATH)/$(file))
159
  @rm -f $(foreach file,$(COBJS),$(OBJ_PATH)/$(file))
160
  @rm -f $(patsubst %.o,%.lst,$(foreach file,$(COBJS),$(OBJ_PATH)/$(file)))
161
  @rm -f $(BIN_PATH)/$(PROJ_NAME).elf $(BIN_PATH)/$(PROJ_NAME).map
162
  @rm -f $(BIN_PATH)/$(PROJ_NAME).srec
163
  @echo +++ Clean complete

von Lukas K. (carrotindustries)


Lesenswert?

Tobi schrieb:
> -nostartfiles

Mach das mal weg.

von Tobi (Gast)


Lesenswert?

Danke hat geklapt

Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.