make:***没有规则来制作目标`main.o'

时间:2011-08-07 18:52:22

标签: eclipse makefile avr

这是Eclipse中控制台的输出:

 **** Build of configuration Debug for project FatFstest ****

make all 
make: *** No rule to make target `main.o', needed by `FatFstest.elf'.  Stop.

我正在尝试使用Eclipse的AVR插件构建一个项目来测试FatFs库。我首先导入了FatFs代码,然后创建了main.c文件来实现它。在我第一次尝试构建它之后,我将项目的src文件夹添加到Properties>中的目录列表中。 AVR编译器>目录,我仍然得到构建错误。有帮助吗?

这是我的makefile:

################################################################################
# Automatically-generated file. Do not edit!
################################################################################

-include ../makefile.init

RM := rm -rf

# All of the sources participating in the build are defined here
-include sources.mk
-include subdir.mk
-include src/subdir.mk
-include objects.mk

ifneq ($(MAKECMDGOALS),clean)
ifneq ($(strip $(C_DEPS)),)
-include $(C_DEPS)
endif
ifneq ($(strip $(ASM_DEPS)),)
-include $(ASM_DEPS)
endif
ifneq ($(strip $(S_DEPS)),)
-include $(S_DEPS)
endif
ifneq ($(strip $(S_UPPER_DEPS)),)
-include $(S_UPPER_DEPS)
endif
endif

-include ../makefile.defs

# Add inputs and outputs from these tool invocations to the build variables 
LSS += \
FatFstest.lss \

SIZEDUMMY += \
sizedummy \

AVRDUDEDUMMY += \
avrdudedummy \


# All Target
all: FatFstest.elf secondary-outputs

# Tool invocations
FatFstest.elf: $(OBJS) $(USER_OBJS)
    @echo 'Building target: $@'
    @echo 'Invoking: AVR C Linker'
    avr-gcc -Wl,-Map,FatFstest.map -mmcu=atmega328p -o"FatFstest.elf" $(OBJS) $(USER_OBJS) $(LIBS)
    @echo 'Finished building target: $@'
    @echo ' '

FatFstest.lss: FatFstest.elf
    @echo 'Invoking: AVR Create Extended Listing'
    -avr-objdump -h -S FatFstest.elf  >"FatFstest.lss"
    @echo 'Finished building: $@'
    @echo ' '

sizedummy: FatFstest.elf
    @echo 'Invoking: Print Size'
    -avr-size --format=avr --mcu=atmega328p FatFstest.elf
    @echo 'Finished building: $@'
    @echo ' '

avrdudedummy: FatFstest.elf
    @echo 'Invoking: AVRDude'
    /usr/local/CrossPack-AVR-20100115/bin/avrdude -pm328p -Uflash:w:FatFstest.hex:a
    @echo 'Finished building: $@'
    @echo ' '

# Other Targets
clean:
    -$(RM) $(OBJS)$(C_DEPS)$(ASM_DEPS)$(ELFS)$(LSS)$(AVRDUDEDUMMY)$(S_DEPS)$(SIZEDUMMY)$(S_UPPER_DEPS) FatFstest.elf
    -@echo ' '

secondary-outputs: $(LSS) $(SIZEDUMMY) $(AVRDUDEDUMMY)

.PHONY: all clean dependents
.SECONDARY:

-include ../makefile.targets

的main.c

#include <diskio.h>
#include <ff.h>
#include <stdio.h>
 int main(void)
 {
   printf("hello world\n");
   return 0;
 }

subdir.mk

################################################################################
# Automatically-generated file. Do not edit!
################################################################################

# Add inputs and outputs from these tool invocations to the build variables 
C_SRCS += \
../src/diskio.c \
../src/ff.c \
../src/main.c 

OBJS += \
./src/diskio.o \
./src/ff.o \
./src/main.o 

C_DEPS += \
./src/diskio.d \
./src/ff.d \
./src/main.d 


# Each subdirectory must supply rules for building sources it contributes
src/%.o: ../src/%.c
    @echo 'Building file: $<'
    @echo 'Invoking: AVR Compiler'
    avr-gcc -I"/Users/nathannewcomb/Documents/Puzzles/FatFstest/src" -Wall -g2 -gstabs -O0 -fpack-struct -fshort-enums -std=gnu99 -funsigned-char -funsigned-bitfields -mmcu=atmega328p -DF_CPU=1000000UL -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -c -o"$@" "$<"
    @echo 'Finished building: $<'
    @echo ' '

objects.mk

################################################################################
# Automatically-generated file. Do not edit!
################################################################################

USER_OBJS :=

LIBS :=

sources.mk

################################################################################
# Automatically-generated file. Do not edit!
################################################################################

O_SRCS := 
C_SRCS := 
S_UPPER_SRCS := 
S_SRCS := 
OBJ_SRCS := 
ASM_SRCS := 
OBJS := 
C_DEPS := 
ASM_DEPS := 
ELFS := 
LSS := 
AVRDUDEDUMMY := 
S_DEPS := 
SIZEDUMMY := 
S_UPPER_DEPS := 

# Every subdirectory with source files must be described here
SUBDIRS := \
src \

4 个答案:

答案 0 :(得分:15)

它也发生在我身上,只是将main.cpp移动到另一个文件夹中。

我尝试清理项目,但问题仍然存在,所以我删除了Debug文件夹,重新编译,它的工作原理!

答案 1 :(得分:1)

不要将main.c放在目录中,把它放在项目的顶部

答案 2 :(得分:0)

  

我将项目的src文件夹添加到我的目录列表中   属性&gt; AVR编译器&gt;目录

删除此/Users/nathannewcomb/Documents/Puzzles/FatFstest/src文件夹并尝试重新编译。

在subdir.mk文件中,行:

avr-gcc -I"/Users/nathannewcomb/Documents/Puzzles/FatFstest/src" -Wall -g2 -gstabs -O0 -fpack-struct -fshort-enums -std=gnu99 -funsigned-char -funsigned-bitfields -mmcu=atmega328p -DF_CPU=1000000UL -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -c -o"$@" "$<"

应该成为:

avr-gcc -Wall -g2 -gstabs -O0 -fpack-struct -fshort-enums -std=gnu99 -funsigned-char -funsigned-bitfields -mmcu=atmega328p -DF_CPU=1000000UL -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -c -o"$@" "$<"

src文件夹已添加到source.mk文件中:

# Every subdirectory with source files must be described here
SUBDIRS := \
src \

答案 3 :(得分:0)

引用eclipse - http://help.eclipse.org/juno/index.jsp?topic=%2Forg.eclipse.cdt.doc.user%2Fconcepts%2Fcdt_c_makefile.htm

Q2。我的控制台视图说没有规则来制作目标'X'。

make -k清理所有 make: *没有规则让目标'干净'。 make:* 没有规则让目标'全部'。 默认情况下,make程序会查找最常称为“Makefile”或“makefile”的文件。如果它在工作目录中找不到这样的文件,或者该文件为空或者文件不包含命令行目标的规则(在这种情况下为“clean”和“all”),则通常会失败并显示错误消息类似于显示的消息。

如果您已有一个有效的Makefile,则可能需要更改构建的工作目录。 build命令的默认工作目录是项目的根目录。您可以通过在Make Project属性中指定备用Build Directory来更改此设置。或者,如果您的Makefile被命名为其他名称(例如buildFile.mk),您可以通过将默认的Build命令设置为make -f buildFile.mk来指定名称。

如果您没有有效的Makefile,请在根目录中创建一个名为Makefile的新文件。然后,您可以添加示例Makefile的内容(上面),并根据需要进行修改。