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?
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.
You need to use quotes instead of <>
for the include, this makes it that the compiler searches in the source file's directory first:
#include "folder/file.h"
Alternatively explicitly add the current directory to your include paths
g++ c -I. main.cc
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With