Closed zXwilt closed 7 months ago
It's a bit late.
With Compile Run, the directory of the file you trigger will be the working directory. In this way when you write #include "header.h"
in your main.cpp
, and trigger Compile Run on the main.cpp
, the compiler will expect header.h
to be in the same directory as main.cpp
.
So in case your folder structure is:
./main.cpp
./inc/header.h
then you have to write #include "inc/header.h"
in the main.cpp
.
Another option is to use the -I
flag of the compiler to specify the directory of headers to be searched for.
In the above example, we can use -Iinc
to let the compiler search headers in inc
directory, then we can simply write "header.h"
in main.cpp
.
When I used gcc-make-run to compile a project, the compiler report this error:
How can I link multiple files with gcc make run?