In my Method.h file:
int method();
In my Method.cpp file:
int metho开发者_高级运维d(){....}
In my Main.cpp file:
method();
In my Makefile
EXEC = main
OBJS = Method.o
.PHONY: all
all: $(EXEC)
main: Main.cpp $(OBJS)
$(CXX) $(CXXFLAGS) $(CPPFLAGS) $(LDFLAGS) $^ -o $@
Method.o : Method.h Method.cpp
When i call make, it says that
Main.cpp: In function ‘int menu()’:
Main.cpp:26: error: ‘method’ was not declared in this scope
make: *** [main] Error 1
Can anybody tell me where I was wrong? Thank you!
Are you sure you include the method.h file in Main.cpp?
My first guess is to change the line
OBJS = Function.o
to
OBJS = Function.o Method.o
Also, Include Method.h
in Main.cpp
// In Main.cpp
#include "Method.h"
精彩评论