i have project files in different directories. directory contains 2 directories b , c, , c contains directory d. files in b, c , d. have written makefiles compile that, main makefile in c. c makefile contains following line :
export ldflags = -i ../b -i . -i ../c/d -lm (at first instead of "../c/d" had written "./d" changed because of error got, sure path valid b. doesn't changed anything)
the makefile in b contains following rule :
%.o : %.c $(cc) $(cflags) -o $@ -c $< $(ldflags) when run "make", there error because file in b has include of file in d, , doesn't find file. why ? !
edit : got same error (same missing file included on same b header file) when added directory -i option, , when had ldflags on b makefile, didn't notice file generating error change : .cpp file include b header including d header provoke error. (don't ask me why there 1 cpp file among c files way, it's not me developed that...) lines cpp file in b makefile :
%.o : %.cpp g++ $(cflags) -o $@ -c $< $(ldflags) but .o of .cpp file not on rule (it call $(objs), define objs = $(src:.c=.o)). guess mistake. because when run make, first go on b directory , compile c file options, , leave directory, because of rule :
b : @(cd $(bdir) && $(make)) so, when make realise myccpfile.o needed, magically call line
g++ -c -o ../b/myccpfile.o ../b/mycppfile.cpp so don't understand call come from, that's odd because rule using g++ have cflags , ldflags, don't understand why disappeared...
its cflags requires -i options compilation phase of build. check b makefile has cflags set appropriate -i options.
ldflags affect linker options.
Comments
Post a Comment