make:***没有制定目标的规则

时间:2013-09-24 08:09:20

标签: c makefile

感谢您的回复。我发现这有效 - 我不知道为什么。

all: $(OUT)

$(OBJ_DIR)/%.o: %.c
        $(CC) $(CCFLAGS) -o $@ -c $< $(INCLUDES)

$(OUT): $(OBJ)
        ar rcs $(OUT) $(OBJ)
        cp DIMEFILEAPPSAUTH.h ../include

.PHONY: clean

下面是我的makefile。我一直收到错误make:*** No rule to make target但是在这种情况下看不出有什么问题。 “.c”文件存在于当前目录中。我不确定为什么makefile看不到它们 - 你能解释一下吗?

DimeFileAppsAuth/src> ls
db_get_DIMEFILEAPPSAUTH.c     db_reset_query_DIMEFILEAPPSAUTH.c  Makefile
db_add_DIMEFILEAPPSAUTH.c     db_print_DIMEFILEAPPSAUTH.c  db_update_DIMEFILEAPPSAUTH.c
db_delete_DIMEFILEAPPSAUTH.c  db_reset_DIMEFILEAPPSAUTH.c

运行make

DimeFileAppsAuth/src> make
make: *** No rule to make target `../obj/db_add_DIMEFILEAPPSAUTH.o', needed by `../lib/lib_dime_file_apps.a'.  Stop.

Makefile

# clear out all suffixes
.SUFFIXES:
# list only those we use
.SUFFIXES: .o .c

# define a suffix rule for .c -> .o
.c.o :
        $(CC) $(CFLAGS) -c $<

FILE_DIVERSION=$(IMG_PROJ_HOME)/dime/basics/BasicsLink

INC_DIR =../include
LIB_DIR =../lib
OBJ_DIR =../obj
BIN_DIR =../bin
CUR_DIR = .

OUT = $(LIB_DIR)/lib_dime_file_apps.a
BIN_OUT = $(BIN_DIR)/test_run

# include directories
INCLUDES = -I$(INC_DIR)  -I$(FILE_DIVERSION)/include  -I$(ORACLE_HOME)/rdbms/public -I/usr/local/include

# library paths
LIBS = -L$(LIB_DIR) -ldime_direct  -L$(FILE_DIVERSION)/lib -loutput_files -lquerylib -lsql_common -lsql_common -L$(ORACLE_HOME)/lib -lclntsh -L$(ORACLE_HOME)/lib `cat $(ORACLE_HOME)/lib/sysliblist` -L/usr/local/lib -lm

CC=gcc
CCFLAGS=-w -O2 -unused-variable -Wall -fPIC  -c -g -rdynamic


_DEPS = DIMEFILEAPPSAUTH.h
DEPS = $(patsubst %,$(INC_DIR)/%,$(_DEPS))

_OBJ = db_add_DIMEFILEAPPSAUTH.o db_delete_DIMEFILEAPPSAUTH.o db_get_DIMEFILEAPPSAUTH.o db_get_SEQ_DIMEFILEAPPSAUTH.o db_print_DIMEFILEAPPSAUTH.o db_reset_DIMEFILEAPPSAUTH.o db_reset_query_DIMEFILEAPPSAUTH.o db_special_DIMEFILEAPPSAUTH.o db_update_DIMEFILEAPPSAUTH.o
OBJ = $(patsubst %,$(OBJ_DIR)/%,$(_OBJ))

_BIN = db_add_DIMEFILEAPPSAUTH.o db_delete_DIMEFILEAPPSAUTH.o db_get_DIMEFILEAPPSAUTH.o db_get_SEQ_DIMEFILEAPPSAUTH.o db_print_DIMEFILEAPPSAUTH.o db_reset_DIMEFILEAPPSAUTH.o db_reset_query_DIMEFILEAPPSAUTH.o db_special_DIMEFILEAPPSAUTH.o db_update_DIMEFILEAPPSAUTH.o test_this.o
BIN = $(patsubst %,$(BIN_DIR)/%,$(_BIN))

all: $(OUT)

$(OBJ_DIR)/%.o: %.c $(DEPS)
        $(CC) $(CCFLAGS) -o $@ $< $(INCLUDES)

$(OUT): $(OBJ)
        ar rcs $(OUT) $(OBJ)
        cp DIMEFILEAPPSAUTH.h ../include

exec: $(BIN) $(OUT)
        $(CC) -o $(BIN_OUT) $(BIN) $(LIBS)
        rm $(BIN_DIR)/*.o

.PHONY: clean

1 个答案:

答案 0 :(得分:1)

当涉及到这行“$(OUT):$(OBJ)”时发生make错误。请检查目录“../ obj”中是否存在名为“db_add_DIMEFILEAPPSAUTH.o”的文件