VC ++ Visual Studio adds .hpp files to a subdirectory, but gets "Error: cannot open source file ..."

It drives me crazy - I added a few .hpp files to subdirectories at the root of the existing VC ++ project source directory.

Visual Studio complains about "Error: cannot open the source file ...", but if I right-click on it and select an open document, VS can display it.

I tried:

  • "Rescan solution" that does nothing.
  • Adding an existing item (both native and using a "filter" - which is a directory?)
  • Closing the project and VStudio in vain hope that eventually it will discover the directories / files that I added.

Does VStudio complain that it cannot find these files when it is able to open them? My question is: "How to add a directory containing source files to a VC ++ project that their linker / corrector can see?

(disclaimer; I have never used Visual Studio before or many Microsoft products, so I think this is all very foreign)

+2
source share
3 answers

Bypass;

Add the files to a directory outside the project, and then refer to these directories in the "Additional inclusion directories" in the properties → Configuration Properties → C / C ++ → General.

Why I can not add additional directories in the project and update them in Visual Studio (for example, updating Eclipse) does not match me.

+3
source

first you need to include any header file that you want to use in your cpp files on #include "path/file.hpp" . in your case, you probably didn't specify a path, for example. "Subdirectory / file.hpp"

0
source

See the answer to the following question. This answer posed a problem for me. It is associated with adding $ (ProjectDir) to the "C / C ++ Include Directory" in the project settings.

"Unable to open include file" error in VS2010

The answer linked above fixed my problem by not including the subdirectory files inside the project. Hope this helps someone else on this.

Thanks,

0
source

Source: https://habr.com/ru/post/1484103/


All Articles