In my favorite tags (cmake) I regularly see questions with the core problem like
I have specified include directory
/some/dir/include/foo
, which contains the headerbar.h
, but compiler cannot resolve#include <foo/bar.h>
.
(Not that every question is actually written in such simple form. Usually this information can be guessed after a few rounds in the comments.)
I don't think that such questions should be closed as "too broad"/"typo" as a very basic problem. Because aspects of relative paths in #include
directive are rarely covered in tutorials.
It could be simpler to comment/answer
Instead, specify include directory
/some/dir/include
but it will carry no information for learning.
Detailed answers could require 1-2 paragraphs (plus another 1-2 paragraphs for adapt general solution for the problem in the specific question), but I would really prefer to connect all such questions to the same target.
What question could be used as a dup target for such sort of problems about #include?
Searching for the error message gives that question. It has highly-upvoted answer which describes many aspects of headers searching procedure, but doesn't cover relative paths.
I could add another answer for that canonical question, but I wonder what others do when process such sort of questions, which, I am pretty sure, exist outside of my favorite tags.
#include <foo.h>
. Is it that the answer does not cover#include <foo/bar.h>
that is the problem?#include <foo/bar.h>
, which requires include directory different than one for#include <bar.h>
.