I'm tying to write a makefile, that should compile (and link) my program. For my program I have to use a bigger Libray with many .h and .cpp files, which comes in a specified filestructure(many other subdirectories)(I'm not allowed to change that stucture) My main.cpp is included in the first directory which also includes the makefile. This.cpp file includes headers out of the bigger library. And here comes the problem, when i try to "make" the terminal says:" fatal error: .. .h: File or Directory not found" #include ".. .h"
BTW: I'm using Ubuntu 18.04.1 with Gcc and gnu-make
Sooo... I tried several things the last 5 days. I tried to do it with a dependfile like this:
SRC = datei1.c datei2.c datei3.c datei4.c datei5.c
CC = /usr/bin/gcc
DEPENDFILE = .depend
dep: $(SRC)
$(CC) -MM $(SRC) > $(DEPENDFILE)
-include $(DEPENDFILE)
(Not sure if i made it the right way)
I was thinking of just including every single header file with include, but that would be waaay to much!
I guess the most powerful and useful thing till now was this URL: Makefile: How to correctly include header file and its directory?. That nearly described perfectly my problem, but it was just useful to include one single header file and not the whole library.
I guess it could be helpful to know how to correctly include a library. (Maybe try some ways over the PATH?)
Folder Sructure:
myproj
|
|____Makefile
|____main.cpp
|____init.cpp
|____end.cpp
|____init.h
|____end.h
|____Dependencies
|____biggerlib
|____src
|____include
|____biggerLib1
|____biggerLib2
|____biggerLib
|____biggerLibrary.h
|____Lib2.h
|____Lib3.h
|____AnotherDirWithFiles1
|____AnotherDirWithFiles2
|____AnotherDirWithFiles3
|____etc.
#include in file:
#include "biggerLib/biggerLibrary.h"
I really do'nt know what to do anymore!
#Compiler directory
CC = gcc
#directories
SDCC = /home/myname/myproj/Dependencies/biggerlib/src
SDCH = /home/myname/myproj/Dependencies/biggerlib/include/biggerLib # normally ere are a few files and more directories!
#Dependenfile
#DEPENDFILE = .depend
#dep: $(SDCC)
# $(CPP) -MM $(SDCC) > $(DEPENDFILE)
#-include $(DEPENDFILE)
#C-Flags for object-compiling
CFLAGS = -c -I$(SDCH)/.. #ugly!
#Deps including every single one? too much work!
#DEPS = $(SDCH)/biggerlibfile.h
#Libs for Compiler
#LIBS = -lSDCH
#Loading object list
include objects.mk
#Main-target (linking)
$(NAME) : $(OBJECTS)
$(CC) -o $(NAME) #$+ $(LIBS)
#Object-targets
%.o : %.cpp #$(DEPENDFILE) #$(DEPS)
$(CC) -o $@ $< $(CFLAGS)
Edit:
The single header file is working, but how do i include all the other header files in the even deeper directories? do I really need to include them all the same way? I need to include every Header behind "include".
I hope u guys understand my problem!:) Looking forward to your suggestions and tips!