all
の私のルールのエコーは適切なものを表示しますが、私がコメントした行にOBJSの定義を移動するとmakefileは動作しません。で、メイクファイルが実行されますが、私はOBJS移動したときに、私は次のエラーを取得するよう:(:=
ではなく)=
で設定このメイクファイルの変数の奇妙な寿命を教えてください
[email protected]$ make
OBJS = other.o main.o
g++ -Wall other.o main.o -o main
g++: error: other.o: No such file or directory
g++: error: main.o: No such file or directory
#MAKEFILE
CPP_COMP=g++
CFLAGS = -Wall
CPP_SRC = $(wildcard *.cpp)
#Define OBJS here and the makefile works. Define OBJS *HERE* it fails as shown below.
OBJS = $(CPP_SRC:.cpp=.o)
all: $(OBJS)
@echo "OBJS = $(OBJS)"
$(CPP_COMP) $(CFLAGS) $(OBJS) -o main
#*HERE*
#Why can't I put CPP_SRC and OBJS here?
#The echo statement above prints out the appropriate value even if I put the variables here.
%.o: %.cpp
$(CPP_COMP) $(CFLAGS) -c $< -o [email protected]
clean:
rm *.o main
Spicerは次のように追加します:**期間**。 :-) – Jens