As stevescripts pointed out, Makefiles are not a big deal. Here's a sample Makefile that you can copy and modify to fit your C++ project:
PHP Code:
SRCS = SourceFile1.cpp SourceFile2.cpp SourceFile3.cpp SourceFileN.cpp
APP = myProgramName
CXXFLAGS = -g
INCPATH = -I../include
OBJS = $(SRCS:.cpp=.o)
LIBPATH = -L../lib
LIBS = -lTCP -lboost_thread-mt
DEP_FILE = .depend
.PHONY: clean cleanall
# Note that from here on down, indented lines commence with a tab-space!
#
$(APP): $(OBJS)
@echo Makefile - linking $<
@$(CXX) $^ $(LIBPATH) $(LIBS) -o $@
clean:
$(RM) *.o core*
distclean: clean
$(RM) $(APP)
$(RM) $(DEP_FILE)
.cpp.o:
@echo Makefile - compiling $<
@$(CXX) $(CXXFLAGS) $(INCPATH) -c $< -o $@
depend:
@$(RM) $(DEP_FILE)
@for i in $(SRCS) ; do \
$(CXX) -E -MM $(INCPATH) $$i >> $(DEP_FILE); \
done
ifeq (,$(findstring clean,$(MAKECMDGOALS)))
ifeq (,$(findstring distclean,$(MAKECMDGOALS)))
-include $(DEP_FILE)
endif
endif
P.S. Important thing to know... to invoke a Makefile, run this command:
Bookmarks