fatal error: file.h: No such file or directory
Here is a potential error message:
make -C library-application install
make[1]: Entering directory '/home/runner/actions-runner-07/student-work/cs3005-202520-proj-xyz/cs3005-202520-proj-xyz/library-application'
g++ -o ApplicationData.o -c ApplicationData.cpp
In file included from ApplicationData.cpp:1:
ApplicationData.h:7:10: fatal error: AudioTrack.h: No such file or directory
7 | #include "AudioTrack.h"
| ^~~~~~~~~~~~~~
compilation terminated.
make[1]: *** [Makefile:8: ApplicationData.o] Error 1
Notice that build is happening in the library-application directory. In trying to fulfill the install target, make
is tyring to compile ApplicationData.cpp
into ApplicationData.o
. ApplicationData.cpp
includes ApplicationData.h
which includes AudioTrack.h
. However, AudioTrack.h
is not found.
Why? AudioTrack.h
is not located in the library-application
directory. Its source is in another library directory. When that library directory is installed, it should copy AudioTrack.h
to the include
folder we install all header files in. So, we should be trying to find the AudioTrack.h
in the include
directory, which has the relative path of ../include
from inside library-application
.
How? The compiler command should be told to look for ../include
in the include directory. This can be done by adding -I ../include
to the compiler command. My Makefile
s use a compile command that looks like this: g++ -I ../include -o $@ -c $<
.
Last Updated 02/05/2025