Reputation: 6682
This is driving me nuts - I've added a number of .hpp files in subdirectories in the root of an existing VC++ projects source directory.
Visual Studio complains "Error: cannot open source file ..." but if I right click on the and select open document, VS can display it.
I've tried:
VStudio complains it cannot find these files when it is capable of opening them? My question is simply this: "How can I add a directory containing source files to a VC++ project such that the linker/complier can see them?
(disclaimer; i've never used Visual Studio before or many Microsoft products, so am finding this all very alien)
Upvotes: 4
Views: 12535
Reputation: 889
Please see the answer at the following question. This answer fixed the problem for me. It has to do with adding $(ProjectDir) in the "C/C++ Include Directory" in the project settings.
"Cannot open include file" error in VS2010
The answer linked above, fixed my issue with not being able to include subdirectory files inside of the project. I hope this helps anyone else having this issue.
Thanks,
Upvotes: 1
Reputation: 6682
Workaround;
Add the files to a directory outside of the project and then reference those directories in the "Additional Include Directories" in Properties -> Configuration Properties -> C/C++ -> General.
Why I can't add additional directories within the project and have Visual Studio rescan them (like an Eclipse refresh) is beyond me.
Upvotes: 5
Reputation: 16266
first you need to include any header file you'd like to use into your cpp files by #include "path/file.hpp"
. in your case your probably didn't specify path, e.g. "subdir/file.hpp"
Upvotes: 1