Issue
When I use type make
into Ubuntu terminal I get:
main.cc:5:30: fatal error: folder/file.h: No such file or directory
The folder exists in the working directory and the file.h exists in the specified folder.
When I type ls
it lists the folder and file in my working directory as well.
Oddly enough, when I open it in geany and ask it to find the file in the
#include <folder/file.h>
it finds it without issue but when it builds it I get the error.
Is there a flag I need to set so it so it includes the folder? If so, what would that look like exactly?
Solution
This depends a bit on your C compiler, but "typically" when you include a file using the < ... >
syntax the compiler will only look for those header files in directories you have specified on the command line with the -I
flag, plus various built-in system directories.
Notably, it usually will not look in the current working directory, unless you explicitly add -I.
to the compile line.
Alternatively, if you use the " ... "
form of #include
, then it will look in the current working directory as well.
So, either switch to #include "folder/file.h"
, or else add -I.
to your compile line.
Answered By - MadScientist