tomlau10 / gcc-make-run

Compile-run C/C++ source code and execute Makefile in Atom.
https://atom.io/packages/gcc-make-run
MIT License
24 stars 10 forks source link

No such file or directory #47

Closed zXwilt closed 7 months ago

zXwilt commented 6 years ago

When I used gcc-make-run to compile a project, the compiler report this error: image

How can I link multiple files with gcc make run?

tomlau10 commented 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.