2015-04-21 90 views
0

問題爲了使用庫的我需要改變一個生成文件來利用交叉編譯器臂-NONE-EABI-G ++的代替臂-NONE-EABI-GCC;但是,由於某些奇怪的原因,我不斷收到No rule to make target錯誤。我刪除了依賴關係,只留下了啓動代碼和main,我也試圖使用文件的絕對路徑。但是,我仍然收到錯誤。有沒有人有什麼建議?與生成文件

PROJECT_NAME=test-liv 

BUILDDIR = build 

LIBDIR = ../common 
DEVICE = $(LIBDIR)/STM32F4xx 
CORE = $(LIBDIR)/CMSIS 
PERIPH = $(LIBDIR)/STM32F4xx_StdPeriph_Driver 
PROJHEADERS = inc 
PROJ_LIBDIR = lib 

#SOURCES = src/main.cpp 
SOURCES = startup_stm32f4xx.S 
SOURCES += system_stm32f4xx.c 
SOURCES += LibraryHacks.cpp 

SOURCES += src/main.cpp 
#SOURCES += $(PERIPH)/src/ 
#PROJECT SOURCES 
#SOURCES += $(PROJ_LIBDIR)/src/ 


OBJECTS = $(addprefix $(BUILDDIR)/, $(addsuffix .o, $(abspath $(basename $(SOURCES))))) 

INCLUDES += -I$(DEVICE) \ 
      -I$(PROJHEADERS) \ 
      -I$(CORE) \ 
      -I$(PERIPH)/inc \ 
      -I$(PROJ_LIBDIR)/inc \ 
      -Isrc \ 
      -I. 

ELF = $(BUILDDIR)/$(PROJECT_NAME).elf 
HEX = $(BUILDDIR)/$(PROJECT_NAME).hex 
BIN = $(BUILDDIR)/$(PROJECT_NAME).bin 

CXX = arm-none-eabi-g++ 
LD = arm-none-eabi-g++ 
AR = arm-none-eabi-ar 
OBJCOPY = arm-none-eabi-objcopy 
GDB = arm-none-eabi-gdb 
SIZE = arm-none-eabi-size 

CXXFLAGS = -O0 -g -Wall -I.\ 
    -std=c++11 -mlittle-endian -mthumb -mcpu=cortex-m4 -mthumb-interwork \ 
    -mfpu=fpv4-sp-d16 -mfloat-abi=hard \ 
    $(INCLUDES) -DUSE_STDPERIPH_DRIVER 

SEMIHOSTING_FLAGS = --specs=rdimon.specs -lc -lrdimon 

LDSCRIPT = stm32_flash.ld 
LDFLAGS += -T$(LDSCRIPT) -mthumb -mcpu=cortex-m4 

$(BIN): $(ELF) 
    $(OBJCOPY) -O binary $< [email protected] 

$(HEX): $(ELF) 
    $(OBJCOPY) -O ihex $< [email protected] 

$(ELF): $(OBJECTS) 
    $(LD) $(LDFLAGS) $(CFLAGS) $(SEMIHOSTING_FLAGS) -o [email protected] $(OBJECTS) $(LDLIBS) 
    $(SIZE) [email protected] 

$(BUILDDIR)/%.o: %.c 
    mkdir -p $(dir [email protected]) 
    $(CXX) -c $(CXXFLAGS) $< -o [email protected] 

$(BUILDDIR)/%.o: %.S 
    mkdir -p $(dir [email protected]) 
    $(CXX) -c $(CXXFLAGS) $< -o [email protected] 

flash: $(BIN) 
    st-flash write $(BIN) 0x8000000 

debug: $(ELF) 
    $(GDB) -tui $(ELF) 

openocd: $(ELF) 
    openocd -f board/stm32f4discovery.cfg 

all: $(HEX) $(BIN) $(ELF) 

functions: all 

.PHONY: clean 
clean: 
    rm -rf build 

編輯:我刪除了其他依賴,離開LibraryHacks和主,並根據whichone完整的錯誤消息首先它仍然給了我同樣的錯誤

mkdir -p build//*Removed*/ 
arm-none-eabi-g++ -c -O0 -g -Wall -I. -std=c++11 -mlittle-endian -mthumb -mcpu=cortex-m4 -mthumb-interwork -mfpu=fpv4-sp-d16 -mfloat-abi=hard -I../common/STM32F4xx -Iinc -I../common/CMSIS -I../common/STM32F4xx_StdPeriph_Driver/inc -Ilib/inc -Isrc -I. -DUSE_STDPERIPH_DRIVER /*Removed*/startup_stm32f4xx.S -o build//*Removed*/startup_stm32f4xx.o 
mkdir -p build//*Removed*/ 
arm-none-eabi-g++ -c -O0 -g -Wall -I. -std=c++11 -mlittle-endian -mthumb -mcpu=cortex-m4 -mthumb-interwork -mfpu=fpv4-sp-d16 -mfloat-abi=hard -I../common/STM32F4xx -Iinc -I../common/CMSIS -I../common/STM32F4xx_StdPeriph_Driver/inc -Ilib/inc -Isrc -I. -DUSE_STDPERIPH_DRIVER /*Removed*/system_stm32f4xx.c -o build//*Removed*/system_stm32f4xx.o 
make: *** No rule to make target `build//*Removed*/LibraryHacks.o', needed by `build/hx8352a-lcd.elf'. Stop. 
+0

它們在路徑中也沒有空格 – kdgwill

+0

如果你把這個makefile和arm-none-eabi-gcc替換成arm-none-eabi-gcc,它可以正常工作嗎? – Beta

+0

當項目只有C是的,但現在當回到arm-none-eabi-gcc並將標誌修改爲c99時,它給了我完全相同的輸出 – kdgwill

回答

2

這條規則:

$(BUILDDIR)/%.o: %.c 

描述瞭如何從foo.c創建文件$(BUILDDIR)/foo.o。但是你現在想編譯一個.cpp文件。只是將配方中的編譯器變量從$(CC)更改爲$(CXX)不會更改目標或先決條件的描述!您需要添加一個新規則告訴make去編譯.cpp文件:

$(BUILDDIR)/%.o: %.cpp 
     mkdir -p $(dir [email protected]) 
     $(CXX) -c $(CXXFLAGS) $< -o [email protected] 

此外,你應該放回%.c食譜$(CC)編譯調用;用C++編譯器編譯C代碼通常不是一個好主意。

+0

謝謝你一切正常builds現在我使用gcc for c和asm文件和g ++ for C++文件。我不會意識到這個錯誤 – kdgwill