简体   繁体   中英

Visual Studio ignoring include directories

I am running Visual Studio Community 2017 and Windows 10. I have a project for which I have added an include-file directory under Project > Configuration Properties > VC++ Directories > Include Directories, but Visual Studio simply ignores the directory and will not find the include files. It finds the files if I hard-code the directory into the #include statement. I checked the .vcxproj file and the directory shows up there. I just updated/corrected Visual Studio to the most recent version and have since re-booted, but the problem remains. Help, please!

First, ensure that MFC is enabled in project properties > Configuration Properties > General use of mfc must be set to static or dynamic library. then to ensure that cl.exe is using all of the include directories that you specify, you need to go to project properties > c/c++ > general and change suppress startup banner to no /nologo.this will give you the full cl command for each source file, showing exactly what visual studio is attempting to do with the code and configuration options that you give to it.

Additional ideas for troubleshooting this kind of issue:

When using vs2015 you can try to add '#include < somenoneexistingfile.h >' to the top of any .c/.cpp and right-click on it to open a context menu and select "Open Document < somenoneexistingfile.h >. This will open a dialog showing you the actual paths being used for including. Note: This specific approach doesn't work with vs2019 or later.

Besides this, you can check if:

  1. you edited the actual configuration (Debug/Release) which you are starting, ie maybe you only edited the additional-include-path for the debug-build but are trying to compile a release-build.
  2. you edited the actual platform (x64 vs x86) which you are starting, ie maybe you only configured the additional-include-path for x86 but are trying to compile the x64 platform.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM