make:***没有规则来制作目标`gcc',需要`Employee.o'。停止

时间:2013-12-12 13:56:39

标签: c++ gcc makefile

我是makefile的新手。你能帮我纠正下面的makefile:

我创建了一个Employee类。 Manager类派生自Employee类。 Link类引用了Employee和Manager类。

错误:

  make: *** No rule to make target `gcc', needed by `Employee.o'.  Stop.

Makefile:

  CC = gcc
  TOP=/usr/local/share/cimple
  ROOT= $(PEGASUS_ROOT)
  ##BINDIR= ${PEGASUS_HOME}/bld/bin
  TARGET = ${PEGASUS_HOME}/lib/libEmployee.so
  LIBRARY_FLAGS = -L${PEGASUS_HOME}/lib
  ##PROVIDERROOT = $(PEGASUS_ROOT)/../providers
  INSTANCE_PROVIDER_OBJECTS = Employee.o Manager.o Link.o module.o repository.o Employee_Provider.o Manager_Provider.o Link_Provider.o

  COMPILE_FLAGS = -W -Wall -g -fPIC
  LINK_FLAGS = -W -Wall -g -shared
  EXTRA_INCLUDES = -I$(PROVIDERROOT) -I${PEGASUS_ROOT}/src

  LIBRARIES = pegcommon pegprovider
  DYNAMIC_LIBRARIES = -lpegcommon -lpegprovider


  include $(TOP)/mak/config.mak

  MODULE=1
  SHARED_LIBRARY=Employee

  ##
  ## Define source files for compile and link
  ##

  SOURCES += Employee.cpp
  SOURCES += Manager.cpp
  SOURCES += Link.cpp
  SOURCES += module.cpp
  SOURCES += repository.cpp
  SOURCES += Employee_Provider.cpp
  SOURCES += Manager_Provider.cpp
  SOURCES += Link_Provider.cpp

  ##
  ## Module defined as Pegasus C++ interface
  ##
  CIMPLE_PEGASUS_MODULE=1
  DEFINES += -DCIMPLE_PEGASUS_MODULE

  LIBRARIES += cimplepegadap
  LIBRARIES += cimple

  include $(TOP)/mak/rules.mak


  ${TARGET} : ${INSTANCE_PROVIDER_OBJECTS} Makefile ${CC} ${LINK_FLAGS}   ${LIBRARY_FLAGS} -o ${TARGET} ${INSTANCE_PROVIDER_OBJECTS} ${DYNAMIC_LIBRARIES}


  Employee.o : Employee.cpp Makefile Employee.h ${CC} ${COMPILE_FLAGS} ${EXTRA_INCLUDES} -c Employee.cpp

  Manager.o : Manager.cpp Makefile Manager.h ${CC} ${COMPILE_FLAGS} ${EXTRA_INCLUDES} -c Manager.cpp

  Link.o : Link.cpp Makefile Link.h ${CC} ${COMPILE_FLAGS} ${EXTRA_INCLUDES} -c Link.cpp

  repository.o : repository.cpp Makefile repository.h ${CC} ${COMPILE_FLAGS} ${EXTRA_INCLUDES} -c repository.cpp

  module.o : module.cpp Makefile module.h ${CC} -DCIMPLE_PEGASUS_MODULE ${COMPILE_FLAGS} ${EXTRA_INCLUDES} -c module.cpp

  Employee_Provider.o : Employee_Provider.cpp Makefile Employee_Provider.h ${CC} ${COMPILE_FLAGS} ${EXTRA_INCLUDES} -c Employee_Provider.cpp

  Manager_Provider.o : Manager_Provider.cpp Makefile Manager_Provider.h ${CC} ${COMPILE_FLAGS} ${EXTRA_INCLUDES} -c Manager_Provider.cpp

  Link_Provider.o : Link_Provider.cpp Makefile Link_Provider.h ${CC} ${COMPILE_FLAGS} ${EXTRA_INCLUDES} -c Link_Provider.cpp

我收到了上述错误。非常感谢任何帮助!提前谢谢!

2 个答案:

答案 0 :(得分:9)

更正makefile以包含"输入"和" Tab"在命令实际制作目标之前的字符,例如像Employee.o这样:

Employee.o : Employee.cpp Makefile Employee.h<ENTER>
<TAB> ${CC} ${COMPILE_FLAGS} ${EXTRA_INCLUDES} -c Employee.cpp

Makefile目标的一般语法是:

targetname: dependencies <ENTER>
<TAB>command to build targetname

参见例如这里有更详细的解释:http://mrbook.org/tutorials/make/

答案 1 :(得分:2)

工具GNU Make需要制表将一些文本视为一个配方。 此外,您可能对模式规则感兴趣。您可以使用通用规则替换所有* .o生成规则(基于模式匹配):

%.o: %.cpp %.h
    ${CC} ${COMPILE_FLAGS} ${EXTRA_INCLUDES} -c $@

此规则将从相应的源/头文件生成任何* .o文件。易于维护! 请注意tab

之前的${CC}...