Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-cloud-platform/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Makefile未运行arm none eabi ar未链接所有.o文件_Makefile - Fatal编程技术网

Makefile未运行arm none eabi ar未链接所有.o文件

Makefile未运行arm none eabi ar未链接所有.o文件,makefile,Makefile,我有下面的Makefile CC=arm-none-eabi-gcc AR=arm-none-eabi-ar vpath %.c src src/peripherals vpath %.o out CFLAGS = -g -O2 -Wall -DUSE_STDPERIPH_DRIVER CFLAGS += -mlittle-endian -mthumb -mcpu=cortex-m4 -mthumb-interwork CFLAGS += -mfloat-abi=hard -mfpu=fpv

我有下面的Makefile

CC=arm-none-eabi-gcc
AR=arm-none-eabi-ar

vpath %.c src src/peripherals
vpath %.o out

CFLAGS = -g -O2 -Wall -DUSE_STDPERIPH_DRIVER
CFLAGS += -mlittle-endian -mthumb -mcpu=cortex-m4 -mthumb-interwork
CFLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16
CFLAGS += -ffreestanding -nostdlib
CFLAGS += -Iinc -Iinc/cmsis -Iinc/peripherals -Iinc/stm32f4xx

OUT_DIR=out

SRCS = misc.c stm32f4xx_adc.c stm32f4xx_can.c stm32f4xx_crc.c stm32f4xx_cryp.c stm32f4xx_cryp_aes.c \
    stm32f4xx_cryp_des.c stm32f4xx_cryp_tdes.c stm32f4xx_dac.c stm32f4xx_dbgmcu.c stm32f4xx_dcmi.c stm32f4xx_dma.c \
    stm32f4xx_exti.c stm32f4xx_flash.c stm32f4xx_fsmc.c stm32f4xx_gpio.c stm32f4xx_hash.c stm32f4xx_hash_md5.c \
    stm32f4xx_hash_sha1.c stm32f4xx_i2c.c stm32f4xx_iwdg.c stm32f4xx_pwr.c stm32f4xx_rcc.c stm32f4xx_rng.c \
    stm32f4xx_rtc.c stm32f4xx_sdio.c stm32f4xx_spi.c stm32f4xx_syscfg.c stm32f4xx_tim.c stm32f4xx_usart.c \
    stm32f4xx_wwdg.c

OBJS = $(SRCS:.c=.o)

.PHONY: libstm32f4.a

all: libstm32f4.a

%.o : %.c
    mkdir -p $(OUT_DIR)
    $(CC) $(CFLAGS) -c -o $(OUT_DIR)/$@ $^

libstm32f4.a: $(OBJS)
    $(AR) -r $(OUT_DIR)/$@ $(OUT_DIR)/$(OBJS)

clean:
    rm -rf $(OUT_DIR)
但是当运行make时,我的.o文件正在生成中,但是调用arm none eabi-get的时候,我把事情搞得一团糟

线路

$(AR) -r $(OUT_DIR)/$@ $(OUT_DIR)/$(OBJS)
这可能是我出错的地方,它的输出是:

arm-none-eabi-ar -r out/libstm32f4.a out/misc.o stm32f4xx_adc.o stm32f4xx_can.o stm32f4xx_crc.o stm32f4xx_cryp.o stm32f4xx_cryp_aes.o stm32f4xx_cryp_des.o stm32f4xx_cryp_tdes.o stm32f4xx_dac.o stm32f4xx_dbgmcu.o stm32f4xx_dcmi.o stm32f4xx_dma.o stm32f4xx_exti.o stm32f4xx_flash.o stm32f4xx_fsmc.o stm32f4xx_gpio.o stm32f4xx_hash.o stm32f4xx_hash_md5.o stm32f4xx_hash_sha1.o stm32f4xx_i2c.o stm32f4xx_iwdg.o stm32f4xx_pwr.o stm32f4xx_rcc.o stm32f4xx_rng.o stm32f4xx_rtc.o stm32f4xx_sdio.o stm32f4xx_spi.o stm32f4xx_syscfg.o stm32f4xx_tim.o stm32f4xx_usart.o stm32f4xx_wwdg.o
arm-none-eabi-ar: creating out/libstm32f4.a
arm-none-eabi-ar: stm32f4xx_adc.o: No such file or directory
make: *** [libstm32f4.a] Error 1
当看到这一点时,out/libstm32f4.a是正确的,但是包含所有*.o文件的第二个子句是完全错误的,只有out/misc.o以out/folder作为前缀,而不是其余的前缀,从而导致错误

如何修复Makefile以使其在./out/中查找.o文件?我在用吗

vpath %.o out
不正确,或者Makefile中的arm none eabi ar指令不正确?

只需更改即可

$(AR) -r $(OUT_DIR)/$@ $(OUT_DIR)/$(OBJS)

$(AR) -r $(OUT_DIR)/$@ $(OUT_DIR)/*.o