2012-12-20 1 views
8

これは混乱します。私は私のMakefileを持っている:GNU全く別の結果を作ります。

OBJECTS = 
INCLUDE_BUILD_PATH = /Users/wen/Projects/include 

# Change compilation settings here 
COMPILE = g++ 
override COMPILE_FLAGS += -O2 

# Change linker/compiler specific settings here 
LD_FLAGS := 
CC_FLAGS := -c -I$(INCLUDE_BUILD_PATH)/bigint 

# Add source extensions here 
SRC_EXT = cpp cc 

# Add header dependencies here 
HEADERS = $(wildcard *.hpp) $(wildcard $(INCLUDE_BUILD_PATH)/*/*.hh) 

# Add source files here 
CC_FILES = $(wildcard *.cpp) $(wildcard $(INCLUDE_BUILD_PATH)/*/*.cc) 
CC_O_BUFFER = $(CC_FILES) 
CC_O_BUFFER := $(CC_O_BUFFER:.cpp=.o) 
CC_O_BUFFER := $(CC_O_BUFFER:.cc=.o) 
OBJECTS = $(CC_O_BUFFER) 

# Change .exe name here 
EXE_NAME = maketest 

# Link object files 

$(EXE_NAME): $(OBJECTS) 
    $(COMPILE) $(COMPILE_FLAGS) $(LD_FLAGS) -o [email protected] $^ 

# Build source files 

define compile_rule 
%.o : %.$1 
     $$(COMPILE) $$(COMPILE_FLAGS) $$(CC_FLAGS) -o [email protected] $$< 
endef 
    $(foreach EXT,$(SRC_EXT),$(eval $(call compile_rule,$(EXT)))) 

# Clean 

clean: 
    rm -f $(OBJECTS) $(EXE_NAME) 

# Debug Build 

debug: 
    @echo "Rerun with COMPILE_FLAGS=-D_DEBUG" 

# Print variables 

print: 
    @echo $(CC_FILES) 
    @echo $(OBJECTS) 
    @echo $(HEADERS) 

それが最初で正常にコンパイルが、それが理由もなく停止し、これが出力された:、

Yoshi-Air:maketest wen$ make 
c++ -c -o maketest.o maketest.cpp 
maketest.cpp:4:10: fatal error: 'BigIntegerLibrary.hh' file not found 
#include "BigIntegerLibrary.hh" 
     ^
1 error generated. 

問題だった私もそれを言いませんでしたMakefileでは "C++"を使いますが、代わりに "g ++"を使います。また、私はCC_FLAGSをクリアしたときに-cがまだそこにあった。それは、それ自身の心を持っているメイクのようなものです。

私は私の変数をプリントアウトするmake printを使用する場合、大丈夫のようだ:任意のヘルプやアドバイス

maketest.cpp /Users/wen/Projects/include/bigint/BigInteger.cc /Users/wen/Projects/include/bigint/BigIntegerAlgorithms.cc /Users/wen/Projects/include/bigint/BigIntegerUtils.cc /Users/wen/Projects/include/bigint/BigUnsigned.cc /Users/wen/Projects/include/bigint/BigUnsignedInABase.cc 
maketest.o /Users/wen/Projects/include/bigint/BigInteger.o /Users/wen/Projects/include/bigint/BigIntegerAlgorithms.o /Users/wen/Projects/include/bigint/BigIntegerUtils.o /Users/wen/Projects/include/bigint/BigUnsigned.o /Users/wen/Projects/include/bigint/BigUnsignedInABase.o 
maketest.hpp /Users/wen/Projects/include/bigint/BigInteger.hh /Users/wen/Projects/include/bigint/BigIntegerAlgorithms.hh /Users/wen/Projects/include/bigint/BigIntegerLibrary.hh /Users/wen/Projects/include/bigint/BigIntegerUtils.hh /Users/wen/Projects/include/bigint/BigUnsigned.hh /Users/wen/Projects/include/bigint/BigUnsignedInABase.hh /Users/wen/Projects/include/bigint/NumberlikeArray.hh 

が理解されるであろう。ありがとう!

更新

私は、コンパイルの予想実行印刷する私のprintを更新:

print: 
    @echo $(CC_FILES) 
    @echo $(OBJECTS) 
    @echo $(HEADERS) 
    @echo "Compiles with:" 
    @echo $(COMPILE) $(COMPILE_FLAGS) $(LD_FLAGS) $(CC_FLAGS) 

結果:

maketest.cpp /Users/wen/Projects/include/bigint/BigInteger.cc /Users/wen/Projects/include/bigint/BigIntegerAlgorithms.cc /Users/wen/Projects/include/bigint/BigIntegerUtils.cc /Users/wen/Projects/include/bigint/BigUnsigned.cc /Users/wen/Projects/include/bigint/BigUnsignedInABase.cc 
maketest.o /Users/wen/Projects/include/bigint/BigInteger.o /Users/wen/Projects/include/bigint/BigIntegerAlgorithms.o /Users/wen/Projects/include/bigint/BigIntegerUtils.o /Users/wen/Projects/include/bigint/BigUnsigned.o /Users/wen/Projects/include/bigint/BigUnsignedInABase.o 
maketest.hpp /Users/wen/Projects/include/bigint/BigInteger.hh /Users/wen/Projects/include/bigint/BigIntegerAlgorithms.hh /Users/wen/Projects/include/bigint/BigIntegerLibrary.hh /Users/wen/Projects/include/bigint/BigIntegerUtils.hh /Users/wen/Projects/include/bigint/BigUnsigned.hh /Users/wen/Projects/include/bigint/BigUnsignedInABase.hh /Users/wen/Projects/include/bigint/NumberlikeArray.hh 
Yoshi-Air:maketest wen$ make print 
maketest.cpp /Users/wen/Projects/include/bigint/BigInteger.cc /Users/wen/Projects/include/bigint/BigIntegerAlgorithms.cc /Users/wen/Projects/include/bigint/BigIntegerUtils.cc /Users/wen/Projects/include/bigint/BigUnsigned.cc /Users/wen/Projects/include/bigint/BigUnsignedInABase.cc 
maketest.o /Users/wen/Projects/include/bigint/BigInteger.o /Users/wen/Projects/include/bigint/BigIntegerAlgorithms.o /Users/wen/Projects/include/bigint/BigIntegerUtils.o /Users/wen/Projects/include/bigint/BigUnsigned.o /Users/wen/Projects/include/bigint/BigUnsignedInABase.o 
maketest.hpp /Users/wen/Projects/include/bigint/BigInteger.hh /Users/wen/Projects/include/bigint/BigIntegerAlgorithms.hh /Users/wen/Projects/include/bigint/BigIntegerLibrary.hh /Users/wen/Projects/include/bigint/BigIntegerUtils.hh /Users/wen/Projects/include/bigint/BigUnsigned.hh /Users/wen/Projects/include/bigint/BigUnsignedInABase.hh /Users/wen/Projects/include/bigint/NumberlikeArray.hh 
Compiles with: 
g++ -O2 -c -I/Users/wen/Projects/include/bigint 

makeは私が何を望むか知っていることを証明する、それが作成されるときそれは完全に異なっています:g++の代わりにc++?!

アップデート2:

c++私のシステムにインストールされ、打ち鳴らすを起動します。アレックス・Bによって

ソリューション:

しかし、コンパイルのコマンドラインから、それはメイクが 暗黙のサフィックスルールを使用しようとしているように見える、とあなたのパターンルールを無視します。

私は.SUFFIXES:を試しましたが、それはノールールが見つかったと報告しました。ありがとう、私は行くとマニュアルを参照してください。

+0

私のアドバイスはありますか? '' BigIntegerLibrary.hh ''が存在するかどうか確認してください。 –

+0

それは何度も私に語られています。それは存在する。問題は、コンパイラにインクルードパスを渡すためにmakeがCC_FLAGSを適切にインクルードしていないことです。 –

+0

そして、私たちに見てみましょう... –

答えて

2

コメントに記載されているように、私の環境(Mac OSX、GNU Make 3.81)で動作するので、あなたが投稿したmakefileが不完全であるか、別のバージョンのMakeを使用している可能性があります。

コンパイルコマンドラインからは、Makeが暗黙のサフィックスルールを使用しようとしているように見え、パターンルールは無視されます。

あなたは、さらにあなたの問題をデバッグすることができますので、接尾辞の空のリストを指定することで、デフォルトのルールを無視するようにしてください伝えることができます。

.SUFFIXES: 
+0

"コンパイルコマンドラインからは、Makeが暗黙のサフィックスルールを使用しようとしていて、パターンルールが無視されているようです。それはそれを完全に説明します。私はそれを調べます。 –

+0

あなたの答えは+ 10でした:D –

関連する問題