I am trying to continue to work on a C++ project that somebody else started. To open the project, I had to install the C/C++ workload; I did that and already restarted my PC.
The project originally targeted a different Windows SDK version than the one that is installed on my PC. This lead to Visual Studio IntelliSense telling me "Cannot open source file" for SDK header files like stdio.h or string.h for example.
I went to the project settings > VC++ Directories > Include Directories > Edit and saw that the variables expanded to the wrong paths. Thus I proceeded to retarget the project to the Windows SDK version that is currently installed on my PC (10.0.17763.0).
Now, if I check the Include Directories, I see that "Inherit from parent or project defaults" is checked, the inherited value is
$(VC_IncludePath)
$(WindowsSDK_IncludePath)
and that this expands to
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.16.27023\include
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.16.27023\atlmfc\include
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Auxiliary\VS\include
C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\ucrt
C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um
C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\shared
C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\winrt
C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\cppwinrt
C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\Include\um
I checked that all of these directories do exist on my machine.
However, VS keeps telling me that it cannot open the source files, even after cleaning and rebuilding the whole solution. The project seems to compile, but the code is all squiggly.
My includes are:
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <float.h>
#include <string.h>
#include <stdarg.h>
#include <limits.h>
#include <locale.h>
#include "svm.h"
Only stdarg.h, limits.h (both from C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.16.27023\include\) and svm.h (in project) work. All other includes have this error; they all come from the directory C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\ucrt, I can find all of them in that directory.
I noticed that when I type #include < and let IntelliSense suggest includes, it also does not suggest those from any of the C:\Program Files (x86)\Windows Kits\10\ subdirectories. These header files are listed in the "External Dependencies" project node though.
StackOverflow is full of questions about this error, but usually about a third party lib or project file, and the answers suggest to check the Include Directories. I did that, and they appear to be complete if I can trust the expanded value, but apparently something is still wrong.
I am basically new to C++ and all the "header magic", so it might be related to the project. I found that the project contains some "stdafx.h" file (which is as I read for precompiled headers), however the project settings say to not use precompiled headers and indeed I cannot see any *.pch file either.
Encouraged by Ted Lyngmo's comment I started to edit one of the imports, when suddenly all errors disappeared and the problem was resolved, although nothing had changed.
I had done that before and it didn't help then, so unfortunately I don't know why it helped the second time. As unsatisfactory as it is - it seems that this was a caching issue after all that even persisted after clean and rebuild.
Maybe the difference was that the second time I edited was after the clean and rebuild of the solution, but I can't guarantee.
I'm not very happy with this outcome, because I would've liked to understand what helped and why, but in the end this solved the problem. So it seems you have to retarget, then clean, then rebuild, maybe restart VS, and edit some imports to force whichever cache there is to be invalidated.
P.S.: Also, in the mean time, go and participate in StackOverflow. Apparently this helps. Thus I'm marking this as community answer.
Related
I'm a beginner and I'm trying to build an open source project for the first time in Windows, but I keep running into file not found errors when building. What I've found so far is that a header file called corecrt.h is located at C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\. This file would include another header file named vcruntime.h. The problem is that vcruntime.h is nowhere to be found in that folder.
I later found that vcruntime.h is located in a separate folder located at C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.25.28610\include. This is strange because I'm not sure why corecrt.h would include a file that is not in its own filepath...
I did the bone-headed thing of just copying over vcruntime.h file to the C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\, but this just shifts the problem down the road because vcruntime.h in turn also includes other header files located at C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.25.28610\include, and so on.
I think the issue lies with Windows itself. I think I'm missing something that's suppose to install additional header files like vcruntime.h to C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\
So far I've tried uninstalling/reinstalling Windows SDK, and just reinstall Windows as a whole, but still no dice to make the missing files appear in that folder. Can someone give me some insight on this? I've asked this question on Reddit but so far nothing has been able to help.
Here's the link to the instructions I'm following on how to build https://wiki.documentfoundation.org/Development/BuildingOnWindows
I'm building using their suggested environment Lode on my Windows 10 machine.
I get C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\ucrt\corecrt.h(10): error: vcruntime.h: No such file or directory
The error occurs right at the build step and I run make 2>&1 | tee build.log
I too had the same issue, but found the cause which was the Include directories were not specified correctly. To fix this I did the following with Visual Studio:
Right click on the project name, and then click on Properties.
Under Configuration Properties, select VC++ Directories.
The Include directories should contain $(VC_IncludePath);$(WindowsSDK_IncludePath); - correct this.
Click OK to save and Bob's your uncle.
I recently tried to install boost libraries in C++ 14, and I added it's include paths like:
Solution Explorer > Project Name > Property Pages > VC++ Directories > "C:\Program Files (x86)\Microsoft Visual Studio 14.0\boost\boost"
I tried to compile after adding this:
#include <boost\variant.hpp>
In Error List window, I can see E1696 - cannot open source file "boost\variant.hpp" and I can't compile like before.
Then I tried with adding a backslash like "C:\Program Files (x86)\Microsoft Visual Studio 14.0\boost\boost\", still didn't work.
I also read this post and explicitly specified it's directory, but even didn't work.
Again, I read this post and did exactly same what is in given answer (as I already built project several times) , but still no success.
However, if I include a library like:
#include "C:\Program Files (x86)\Microsoft Visual Studio 14.0\boost\boost\variant.hpp"
Now compiler recognizes it, but now I can see more than 100 errors in Error List window, those errors are pointed to header files of boost libraries, not in my project file which has variant.hpp included.
All those errors are E1696 - cannot open source file "boost\<libraryname.hpp>" or E1696 - cannot open source file "boost\<subdirs>\<some other files included in libraryname.hpp>"
So, if I remove the line #include "C:\Program Files (x86)\Microsoft Visual Studio 14.0\boost\boost\variant.hpp" from my project's header file, all errors disappear suddenly and project compiles fine! no any single error now!
I want boost to work anyway, so I can use it in projects, but I can't manually edit all those header files and change <boost\... to original locations.
Please help me to get rid of this issue.
make sure you download and install the correct boost version. Installing it in the visual studio directories is possible, but not advised. I suggest you use one of the packages from here. Assuming you use visual studio 2017 and you are developing for 64bit, this could perhaps be the correct package for you.
make sure you do both: adding the include search path and the library search path to your visual studio.
The include search path should point to the boost-installation root directory (the one that contains the Jamroot file and a boost subdirectory). The library search path should point to the correct library subfolder within the boost installation. This is one of the subfolders that start with lib64-msvc-**.* (or lib32-msvc-* if you're developing for 32bit).
The default install path of the binary boost package above will install it into C:\local\boost_<boost version>. Make sure you use the paths from this installation directory and follow the instructions here.
Example:
Include search path: C:\local\boost_1_64_0
Library search path: C:\local\boost_1_64_0\lib64-msvc-14.1
I often find that I have problems getting visual studio to find my headers and I think I might have finally found out why: it seems that visual studio does not understand multiple relative directories in project configurations, e.g:
When that directory certainly does exist.
My question is: can somebody confirm this is the case and, if so, is there a reason why they'd do this? Is it a bug or intentional?
Posting as an answer as I can't really fit this into a comment although its a bit frowned upon...
The easiest way to debug this is to run Process Monitor from here, and add a filter to only show access to your file name. I made an example c++ project which tried to load a non existant header #include "Bobby.h" and then added the following filter to Process Monitor:
Path Contains Bobby.h Include
Then I ran the build and got the following output:
CreateFile C:\Users\MyUserName\Documents\Visual Studio 2012\Projects\ConsoleApplication2\ConsoleApplication2\Bobby.h NAME NOT FOUND
CreateFile C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\Bobby.h NAME NOT FOUND
CreateFile C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\atlmfc\include\Bobby.h NAME NOT FOUND
CreateFile C:\Program Files (x86)\Windows Kits\8.0\Include\um\Bobby.h NAME NOT FOUND
CreateFile C:\Program Files (x86)\Windows Kits\8.0\Include\shared\Bobby.h NAME NOT FOUND
CreateFile C:\Program Files (x86)\Windows Kits\8.0\Include\WinRT\Bobby.h NAME NOT FOUND
From this output you can easily see where the compiler searched for the header file - It may be good enough to help you understand why it didn't find it.
HTH
I am trying to compile the Microsoft CRT 11 by myself (The version that comes along with VS2012).
I'm aware that until VS2008 this action was completely supported by Microsoft:
http://msdn.microsoft.com/en-us/library/k9a8ehy3(v=vs.90).aspx
But since VS2010 you are not supposed to do it anymore, and I'm aware of the risks (mainly - compiling it wrong, and having problems that you can't figure or solve)
I'm using the following directories that come with VS as input code and header files:
Code:
C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\crt\src
Headers:
C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include
C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Include
C:\Program Files (x86)\Windows Kits\8.0\Include\shared
C:\Program Files (x86)\Windows Kits\8.0\Include\um
C:\Program Files (x86)\Windows Kits\8.0\Include\WinRT
(So far the only changes I have made are to remove some MSIL sources from the project)
Most of the code compiles already. But I can't compile the file
C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\crt\src\assert.c
Because of the error:
error C3861: '_ReturnAddress': identifier not found
If I add
#include <intrin.h>
it is solved. But I think it's supposed to be solvable without direct changes to the code.
Of course I'm constantly facing new challenges. But I think the solution to the current one is to fix the include order of the header directories. In which order should the header directories be used?
You can force an include (without changing the source code) in the visual studio project (although I'm not sure if it's a better solution).
To do so, right click on the .c in the solution explorer then go in C/C++ -> Advanced -> Force Include File and add intrin.h (or add /FI"intrin.h" in the command line).
Before you try to link me to some other question, please read everything. I am getting this error but I have everything set up correctly. It's not my first time with c++. i am a moderate user and have never had this issue before nor am I having it with any of my other projects.
I'll start off my saying that the file, "D3DX10.h", does exist in "C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Include".
The "DXSDK_DIR" system variable points to "C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\".
My Include Directories for the project for all configurations includes "$(DXSDK_DIR)Include".
Now when I try #include <D3DX10.h>, I get "error C1083: Cannot open include file: 'D3DX10.h': No such file or directory" but when i try '#include "C:/Program Files (x86)/Microsoft DirectX SDK (June 2010)/Include/D3DX10.h"', it does infact build and runs with no errors.
Has anyone ran accross this issue and is there anyway to fix it?
Again, please keep in mind that i have other projects that get "D3DX10.h" using the system variable. That is not the issue here.
ha! I got it! It's the parent project that needs to also have the environment variables defined most likely because my library uses some variables directly from D3DX10.h.