我想製作一個makefile,它可以爲CppUTest生成一個exe文件。它無法找到標題,我做錯了什麼?第一次做makefile,不是100%確定我在做什麼。CPPUTestMakeFile幫助鏈接
#The compiler to use
CC = g++
LINK = -g -pedantic -Wall -lstdc++ -lpthread -ldl -lm -Wl,-rpath,.
COMPILE = -g -O3 -D_THREAD_SAFE -pedantic -Wall -c -Wno-deprecated
#Name of the EXE file to create.
EXE = ./Tests
SRCS = $(shell ls *.cpp)
OBJS = $(subst .cpp,.o,$(SRCS))
#Extra flags to give to the C compiler.
CFLAGS =
#Libraries to include
LIBS= -lCppUTestExt -lCppUTest -lm
#Extra flags to give to the C++ compiler.
CXXFLAGS = -I/home/mg/DS-5-Workspace/Tests/include
#Extra flags to give to compilers when they are supposed to invoke the linker, ‘ld’,
#such as -L. Libraries (-lfoo) should be added to the LDLIBS variable
#instead.
LDFLAGS = -L/home/mg/DS-5-Workspace/Tests/cpputest/lib
#Extra flags to give to the C preprocessor and programs that use it (the C and
#Fortran compilers).
CPPFLAGS =
.SUFFIXES: .o .cpp
.cpp.o:
$(CC) $(CFLAGS) $(CXXFLAGS) $(LDFLAGS) $(COMPILE) $(LIBS) $<
all: $(OBJS)
$(CC) $(CFLAGS) $(CXXFLAGS) $(LDFLAGS) $(LIBS) $(OBJS) -o $(EXE) $(LINK)
-include depend.mak
depend:
g++ -MM $(SRCS) > depend.mak
#static:
#ar -crvs $(a) $(OBJS)
#shared: $(OBJS)
#$(CC) -shared -Wl,-soname -lc -o $(so) $(OBJS)
clean:
rm -rf $(OBJS) depend.mak $(EXE) $(so) $(a)
我有以下錯誤:
error: CppUTest/CommandLineTestRunner.h: No such file or directory
哇,謝謝,這有幫助。如你所知,這是我的第一個makefile。我仍然有錯誤「未定義引用CommandLineTestRunner :: RunAllTests(int,char **)'」它現在找到頭,但不能運行代碼。 – user1876942
那麼,現在這不再是一個生成文件錯誤。所有.cpp文件都與Makefile位於同一目錄中嗎? – Chnossos
我所有的.cpp文件都在同一個目錄中。我是否也需要將CppUTest文件放在那裏?無論如何,我會將答案標記爲正確的,我想也不會出現makefile錯誤。謝謝。 – user1876942