So, for instance I have a bunch of files:
root-dir:
dir-a:
read.cpp
dir-b:
code.cpp
lib.cpp
lib.h
lib’s files:
//lib.cpp
#include <string>
using namespace std;
string edit(string in) {
string out;
/*function body*/
return out;
}
//lib.h
#include <string>
std::string edit(std::string in);
I need to include lib’s function in both “read.cpp” and “code.cpp”.
I tried to:
-
#include "lib.cpp"
from both files, but it failed:fatal error: lib.cpp: No such file or directory
-
#include "lib.h"
. Same:fatal error: lib.h: No such file or directory
-
#include "root-dir/lib.h"
, it highlights red:'root-dir/lib.h' file not found
Obviously, #include "C:/.../.../root-dir/lib.h"
is not a proper solution.
Kira Egen is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.