2013-12-12 111 views
1

我對makefile相當陌生。你能幫我糾正一下下面的makefile:make:***目標`gcc'沒有規則,'Employee.o'需要。停止

我已經創建了一個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 

我收到上述error.Any幫助將非常感謝!提前致謝!

+2

添加進入和製表符。在makefile中他們是至關重要的。 – elyashiv

回答

9

修正makefile以在實際製作目標的命令之前包含「Enter」和「Tab」字符,例如,像這樣的Employee.o:

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

的生成文件目標的一般語法是:

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

參見例如這裏有更詳細的解釋:http://mrbook.org/tutorials/make/

2

GNU Make需要製表工具將一些文本視爲配方。此外,您可能對模式規則感興趣。你可以用普通的一個(基於模式匹配)替換所有*的.o生成規則:

%.o: %.cpp %.h 
    ${CC} ${COMPILE_FLAGS} ${EXTRA_INCLUDES} -c [email protected] 

此規則將生成相應的源/頭文件中的任何* .o文件。易於維護! 注意之前${CC}...

+0

@nyarlathotep:非常感謝您的即時幫助!有效!非常感謝! –

+0

非常感謝。我也會嘗試這個選項:) –

相關問題