我的第一个较大的makefile项目遇到了麻烦。 我在c ++项目中使用了更大的Library。更准确的说:在我的.cpp文件和.h文件中,我需要在这个更大的库中包括一些头文件。
这是我的结构,以让您知道我在项目中如何使用该库:
myproj
|
|____Makefile
|____main.cpp
|____init.cpp
|____end.cpp
|____init.h
|____end.h
|____Dependencies
|____biggerlib
|____bin
|____...
|____include
|____#more directories including
#the Library headers
|____...
|____src
|____biggerLib1
|____biggerLib2
|____biggerLibrary.cpp
|____...
|____Lib2.cpp
|____...
|____Lib3.cpp
|____...
|____Util
|____DebugOut.cpp
|____Dev
|____Data
|____etc.
|____makestuff
|____...
|____...
|____...
|____...
|____codestuff
|____...
|____...
|____...
|____...
|____etc.
我不允许更改该结构。
所以,我的问题是,如果我启动make,gcc或g ++找不到我的输入文件。 错误代码:
g++: fatal error: no input files
compilation terminated.
*makefileName*:21: recipe for target '*Name*' failed
make: *** [*Name*] Error 1
因此,这里有一些我的makefile文件: 首先,我的OBJECTS文件:
OBJECTS += \
$(BUILD)main.o \
$(BUILD)init.o \
$(BUILD)end.o
然后创建我的文件:
#Name (output name / project name)
NAME = proj
#Compiler directory
CC = gcc
CPP = g++
#Libray directorys
SDCC = /home/myname/myproj/Dependencies/biggerlib/src/biggerLib2/Util
# the headers are working well since yesterday but now i got the trouble with the input stuff...
#C-Flags for object-compiling
CFLAGS = -O2 -g3 -c -I$(SDCHDR) -I$(SDCDATAMODEL) -I$(SDCPOCO) #may i have to add here the source files too? did not work...
#Main-target (linking)
$(NAME) : $(OBJECTS)
$(CPP) -o $(NAME) -I$(SDCC)/DebugOut.cpp ## this one was just to try if I could bind in one single .h file...
#Object-targets
%.o : %.cpp
$(CPP) -o $@ $< $(CFLAGS)
我的make命令:
make -f makefilename
如果您中的任何人都知道我可以在不更改目录结构的情况下包括丢失的输入文件,那就太好了。