Search code examples
cgccmakefile

The headers can't be found by gcc


I have included the header file in each source file,but it fails to find them when I usemakecommand. These header files included are simple and located in the same project directory.

In file included from tests/list_tests.c:1:
tests/minunit.h:6:10: fatal error: dbg.h: No such file or directory
    6 | #include "dbg.h"
      |          ^~~~~~~
compilation terminated.

Below are all the project files:

.
├── bin
├── LISENSE
├── Makefile
├── README.md
├── src
│   └── lcthw
│       ├── dbg.h
│       ├── list_algos.c
│       ├── list_algos.h
│       ├── list.c
│       ├── list.h
│       ├── queue.h
│       ├── ringbuffer.c
│       ├── ringbuffer.h
│       ├── stack.h
│       └── tags
├── tags
└── tests
    ├── list_algos_tests.c
    ├── list_tests.c
    ├── minunit.h
    ├── queue_tests.c
    ├── runtests.sh
    ├── stack_tests.c
    └── tags

I have tried to add-I *PATH* to gcc but it fails to find files either. And I add PATH to .bashrc then usemake,it also can't find files.


Solution

  • You use -Isrc, but the file dbg.h is in the directory src/lcthdw. Change the directory for the -I flag (or add another -I flag with the src/lcthdw directory).