Visual Studio 2012 alongside 2010 - kernel32.lib, windows.h - c++

I just installed Visual Studio 2012 alongside Visual Studio 2010. The problem is that I can't manage to convert simple projects from 2010 to 2012 - they fail to link to files such as kernel32.lib or include files such as windows.h. My system also has Windows SDK 7.1 installed.
I have tried messing with Property Manager for my x86 and x64 user platforms (since I had appropriate $(DXSDK_DIR) references added there), only to get mixed results - sometimes it just works, sometimes it compiles but doesn't link, other times it simply stops at windows.h
For example, currently I'm getting
1>LINK : fatal error LNK1104: cannot open file 'kernel32.lib'
or
1>Source.cpp(2): fatal error C1083: Cannot open include file: 'windows.h': No such file or directory
(depending on the inclusion or not of "windows.h") with a simple "hello world" type program only in x64.
In the project properties for Active(Debug) / Active(x64) -> VC++ Directories -> Include Directories I can now see $(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSDK_IncludePath);$(DXSDK_DIR)Include. If I expand that input box and I click Edit, I see:
$(VCInstallDir) = C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\
$(WindowsSDK_IncludePath) = c:\Program Files (x86)\Windows Kits\8.0\Include\um;c:\Program Files (x86)\Windows Kits\8.0\Include\shared;c:\Program Files (x86)\Windows Kits\8.0\Include\WinRT
While my platform toolset v110 windows.h resides at c:\Program Files (x86)\Windows Kits\8.0\Include\um\Windows.h (so there should be no problem). Stuff works if I select Windows SDK 7.1 as platform toolset.
Any solution besides formatting and reinstalling Windows?
L.E. if I replace the $(variable) directories with absolute paths within the system, everything works. I don't see why I would do this, since I am sharing the project with others as well.

I know there's almost an answer above. But...
The problem seems to be that when VS2012 and VS2010 are installed, the configuration for VS2012 does not work correctly.
The fix is to edit the props files in %home%\AppData\Local\Microsoft\MSBuild\v4.0.
These are the files that worked for me, using SDK v8.1.
First Microsoft.Cpp.Win32.user.props which is used for 32-bit builds:
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<IncludePath>C:\Program Files (x86)\Windows Kits\8.1\include\um;C:\Program Files (x86)\Windows Kits\8.1\include\shared;C:\Program Files (x86)\Windows Kits\8.1\include\winrt;$(IncludePath)</IncludePath>
<LibraryPath>C:\Program Files (x86)\Windows Kits\8.1\Lib\winv6.3\um\x86;$(LibraryPath)</LibraryPath>
<ExecutablePath>C:\Program Files (x86)\Windows Kits\8.1\bin\x86;$(ExecutablePath)</ExecutablePath>
</PropertyGroup>
</Project>
Now Microsoft.Cpp.x64.user.props which is used for 64 bit builds:
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<IncludePath>C:\Program Files (x86)\Windows Kits\8.1\include\um;C:\Program Files (x86)\Windows Kits\8.1\include\shared;C:\Program Files (x86)\Windows Kits\8.1\include\winrt;$(IncludePath)</IncludePath>
<LibraryPath>C:\Program Files (x86)\Windows Kits\8.1\Lib\winv6.3\um\x64;$(LibraryPath)</LibraryPath>
<ExecutablePath>C:\Program Files (x86)\Windows Kits\8.1\bin\x64;$(ExecutablePath)</ExecutablePath>
</PropertyGroup>
</Project>
I hope this helps others with this problem, I haven't found a solution posted anywhere else.

I had a similar problem.
In my case this was because the correct paths weren't inherited in the project settings.
Check that the paths are inherited in: Project -> Properties -> VC++ Directories
Under Include and Library Directories go to Edit.
Make sure that the Inherit from parent or project defaults is checked.
The VS2012 default properties and Macros were set correctly. (Although I had the common installation problems where I had to replace all the VC directory because it didn't even install the C++ core libraries)

Related

Cannot open include file: 'stddef.h': No such file or directory in cstddef QtCreator

When I want to compile my Qt project, debuger shows me that stddef.h was not included into ...\VC\Tools\MSVC\14.27.29110\include. I tried to solve this problem using adding to system Environmental Variables path to Win SDK Kits (folder include). But this doesnt solve my problem. Also I instaled Windows Universal CRT SDK but this giving me nothing. Also I tried to reinstall VS and Qt,check Qt for update, add to environment variable PATH path to folder bin from MSVC folders and change include in cstddef from stddef.h to stddef. This is the list of my environment variable PATH:
C:\Program Files\Microsoft SQL Server\130\Tools\Binn\
C:\Program Files\dotnet\
C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\170\Tools\Binn\
C:\Program Files (x86)\Windows Kits\10\Windows Performance Toolkit\
C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0
And this is user environment setting PATH:
C:\Users\karat\AppData\Local\Programs\Python\Python37-32\Scripts\
C:\Users\karat\AppData\Local\Programs\Python\Python37-32\
C:\Users\karat\AppData\Local\Microsoft\WindowsApps
C:\Program Files\JetBrains\PyCharm Community Edition 2019.2.1\bin
C:\Users\karat.dotnet\tools
%USERPROFILE%\AppData\Local\Microsoft\WindowsApps
%USERPROFILE%.dotnet\tools
Could you recommend me a way to solve this problem and tell me why this could happen at all?

vcruntime.h missing from Windows include folder?

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.

MSBuild 2019 ignores INCLUDE environment variable

I am working with two machines that have Visual Studio 2019. One has Community edition, the other has Pro edition.
The pro edition of MSBuild is completely ignoring the INCLUDE environment variable, so the project I'm trying to build (ICU) cannot find stddef.h. The stddef.h file is in the Windows Kits 10 ucrt directory, which is included in the INCLUDE env var.
The community edition doesn't do this.
When I build the project with the /v:diag option I can see most of what's defined in the INCLUDE env var is added to a variable named CAExcludePath.
Here's the INCLUDE env var: INCLUDE=C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.24.28314\include;;C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.24.28314\atlmfc\include;;C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Auxiliary\VS\include;;C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt;;;C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Auxiliary\VS\UnitTest\include;C:\Program Files (x86)\Windows Kits\8.1\Include\um;C:\Program Files (x86)\Windows Kits\8.1\Include\shared;C:\Program Files (x86)\Windows Kits\8.1\Include\winrt;;
And here's the CAExcludePath: CAExcludePath=C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.24.28314\atlmfc\include;C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.24.28314\include;C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt;;C:\Program Files (x86)\Windows Kits\8.1\Include\um;C:\Program Files (x86)\Windows Kits\8.1\Include\shared;C:\Program Files (x86)\Windows Kits\8.1\Include\winrt;;
Why does this happen and how do I prevent it?
MSBuild 2019 ignores INCLUDE environment variable
I think you should not set these paths into Environment Variables. For C++ projects, VS does not recognize the library path in system environment variables by default and this is not the VS job.
Usually, you should set extra library paths in VS IDE. Right-click on your project-->Properties-->Configuration Properties-->VC++ Directories-->Include Directories or Properties-->Configuration Properties-->C/C++-->Additional Include Directories. You can refer to this official document.
However, when l install Windows Kits tool, this path is included in the include path by default and you can use this in your code directly. See this:
So l am afraid you have something wrong when you install the Windows Kits tool. Please follow this document to install the right tool and before you finish it, please install the related extension which is the last step in the installer in Visual Studio 2019 to integrate the tool.
I think when you install the extension, these paths will be included into VS automatically and you can use them directly.
Besides, if you do not want to install this extension, you can add the include path manually by the steps I mentioned above.
If you have done these steps and still faced the same error, I think you should check your Environment and follow these suggestions:
1) close VS Instance, delete .vs, bin, obj folders,reopen your project and then build again
2) do a repair in VS Installer
3) if your VS is not the latest, please update your VS and do not forget to update Operation System at the same time.
Hope these help.
Use the IncludePath environment variable instead.
set IncludePath=%INCLUDE%
IncludePath is not ignored/overwritten when running msbuild, and I was able to successfully compile my project/solution by setting it.
On my machine, setting IncludePath overrides 3 paths which would otherwise be set. The 3 paths have analogs (same header files but for different versions) in my %INCLUDE% paths, so it seems safe (and in fact prudent) to ignore/clobber/leave these out.

Compiling Microsoft CRT 11 (msvcrt110.dll) - What is the correct order of includes?

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).

d3dx11.h missing?

So I've reinstalled directx11 a couple times and even went to the Microsoft website and got the SDK pack that has all the direct x cabinet files in it. Anyone have any idea why i keep getting this error then? I know why it is saying it but more looking for the solution to it.
1>c:\users\vaughn\documents\visual studio
2010\projects\myfirstapp\myfirstapp\main.cpp(5): fatal error C1083:
Cannot open include file: 'd3dx11.h': No such file or directory
That's what you need to do in VS 2010 (it looks a bit different in VS 2008 and earlier):
Go to your project's properties | Configuration Properties | VC++ Directories. Edit line called Include Directories by adding path to DirectX header files. As for June 2010 SDK it may be something like:
32 bit Win: C:\Program Files\Microsoft DirectX SDK (June 2010)\Include
64 bit Win: C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Include
Next you are most likely to get a linker's error (missing .lib files). Just go to your project's properties | Configuration Properties | VC++ Directories again, but this time edit Library Directories and add to one of the following paths:
32 bit Win: C:\Program Files\Microsoft DirectX SDK (June 2010)\Lib\x86
64 bit Win: C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Lib\x64
If you installed other version of SDK or installed it to non-default directory change given paths accordingly. Also make sure you added d3d11.lib (and maybe d3dx11.lib as well) to Linker | Additional Dependencies.
General rule is that any time you #include <> files your IDE needs to know where to find them. VC++ Directories is one way of doing that in Visual Studio. But sole inclusion of headers is (in most cases) not enough - you need to tell your linker where to look for precompiled binaries described by those headers. That what you do by adding the second path to Library Directories.
You have to make sure you get the latest DirectX SDK. It has the header files. If all you got were cabinet files, you got the wrong SDK.
In my case, for DX12, I was missing d3dx12.h
See this MSDN page.
In case the page moves, the relevant line appears to be
"d3dx12.h is available separately from the Direct3D 12 headers. You can download d3dx12.h by navigating into any of the source files for the Direct3D 12 projects at GitHub/Microsoft/DirectX-Graphics-Samples"