0

I am working on a project with the following dir structure.

prog/
    Makefile
    src/
        module1/
        module2/
        common/
            util.c
            util.h           # include "common/info.h"
            info.c
            info.h
    test/
        perf/
            Makefile
            src/
                test.c

I needed a use functions of prog/src/common/util.c in prog/test/src/test.c
I copied all files from prog/src/common/* in new folder prog/test/src/common/
Then I added the INC_DIR in CFLAGS of Makefile

prog/test/perf/Makefile:

INC_DIR = src/common
DFLAGS  = -MT $@ -MD -MP -MF $(O)/$*.d
CFLAGS  = -Wall -Werror $(OPT) $(STD) -I$(INC_DIR)../

but i am still getting error when i make

src/common/util.h:4:24 fatal error common/info.h: No such file or directory

I checked that prog/test/src/common/info.h does exist. I am not so good at Makefile syntax. What am i doing wrong.

kernelman
  • 992
  • 1
  • 13
  • 28
  • It's not the Makefile syntax, it's the paths you provide. You tell the compiler to search "src/common" and give it a file "common/info.h". Do you see the error? It looks for "src/common/common/info.h" – the busybee Aug 25 '21 at 10:14
  • `-I` flag is `src/common/../` I referred this ans : https://stackoverflow.com/a/22545645 – kernelman Aug 25 '21 at 10:21
  • 1
    Oh, I overlooked that you changed the path in the option, sorry. However, actually it's "src/common../" (no slash before the dots). – the busybee Aug 25 '21 at 11:50

0 Answers0