MSBuild 2019 ignores INCLUDE environment variable - c++

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.

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?

TRK0005 error locating rc.exe building VC++ 2015 project

I have a VS 2015 C++ project (64-bit Windows 10 + Windows 10 SDK).
With the Project Properties > General > Target Platform Version set to "8.1", everything builds fine.
When I change it to "10.0.15063.0", I hit this error:
Error TRK0005 Failed to locate: "rc.exe". The system cannot find the file specified.
I saw from other posts that the fix is to paste the exe to somewhere it can be found. I'm looking for something a bit more solid (e.g. version controlled).
When set to 8.1, the $(WindowsSDK_ExecutablePath) macro includes this path:
C:\Program Files (x86)\Windows Kits\8.1\bin\x86
with rc.exe in it.
When set to 10.0.15063.0, none of the paths in the macro have an rc.exe inside them. If I add this path to the Executable Directories, the problem goes away:
C:\Program Files (x86)\Windows Kits\10\bin\10.0.15063.0\x64
My questions:
Is what I'm seeing expected or should rc.exe be found out-the-box?
Is it safe for me to add this extra path or am I likely to break something?
Am I using the correct extra path? (The 8.1 path includes "x86".)
Thanks
1) rc.exe should be found out of the box.
The issue may be related to a different Windows 10 SDK path schemes which was changed in newer Windows 10 SDKs.
Please, check, if VS2015 files point to the folder
C:\Program Files (x86)\Windows Kits\10\bin\x64
(You can see the value of the macro for $(WindowsSDK_ExecutablePath)).
Latest Windows 10 SDK are installed in parallel subfolders so you may install different Windows 10 SDK, with folders like:
C:\Program Files (x86)\Windows Kits\10\bin\10.0.15063.0\x64
C:\Program Files (x86)\Windows Kits\10\bin\10.0.17763.0\x64
If VS expects SDK in general folder - Windows Kits\10\bin\, you may copy rc.exe, rc.dll there from bin\10.0.15063.0\ (from \x86 to \x86, from \x64 to \x64).
This is inconsistency in VS2015 / Win 10 SDK install.
2) If you put actual rc.exe path into the Project Properties > Configuration Properties > Executable Directories, at the end, it is generally safe. Paths are iterated from left to right, and the last one will be searched only if .exe was not found in the previous predefined ones.
3) VS may build .rc resource files always with 32-bit rc.exe from \x86 folder, depending on the variable in Executable Paths. It may be set to $(WindowsSDK_ExecutablePath).
This actually should not matter, as these are 32-bit / 64-bit versions of the compiler executables with equivalent functionality.
You can track which compiler .exe files MSBuild invokes in Output window, if increase verbosity:
Tools > Options > Projects and Solutions > Build and Run > MSBuild project build output verbosity > Detailed.
Not the cleanest solution but here's how I solved it, as #Alexey said, I also have 2 SDKs, 10 and 8.1 and probably that's where the error came from.
I just added the path:
C:\Program Files(x86)\Windows Kits\8.1\bin\x64
to the PATH in Windows environment variables
Note: The x64 at the end of the path, needs to be changed if you are compiling for a different architecture.
In addition, the path is where the rc.exe is located on my PC, you should make sure that it is indeed in the same place on your PC as well.
Do not forget to close and reopen Visual Studio after the change to update the environment variables.
I installed one of the latest Windows SDK version, 10.0.19041.0,and found that the rc.exe is there the architecture folder under the SDK version in the bin folder. Here is what I mean:
C:\Program Files (x86)\Windows Kits\10\bin\10.0.19041.0\x64
I found a number of default Macros already created so I use them to make the path more generic in case if I have to change the platform target to a differernt version.
This is the path using the Macro and it's working for me.
$(WindowsSdkDir)bin\$(WindowsTargetPlatformVersion)\$(PlatformTarget)
So, the rc.exe is there. You just need to find where it is and add its path to the VC++ Directories\Executable Directories in the configuration dialog.

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

How do you install GLUT and OpenGL in Visual Studio 2012?

I just installed Visual Studio 2012 today, and I was wondering how can you install GLUT and OpenGL on the platform?
OpenGL should be present already - it will probably be Freeglut / GLUT that is missing.
GLUT is very dated now and not actively supported - so you should certainly be using Freeglut instead. You won't have to change your code at all, and a few additional features become available.
You'll find pre-packaged sets of files from here:
http://freeglut.sourceforge.net/index.php#download
If you don't see the "lib" folder, it's because you didn't download the pre-packaged set.
"Martin Payne's Windows binaries" is posted at above link and works on Windows 8.1 with Visual Studio 2013 at the time of this writing.
When you download these you'll find that the Freeglut folder has three subfolders:
- bin folder: this contains the dll files for runtime
- include: the header files for compilation
- lib: contains library files for compilation/linking
Installation instructions usually suggest moving these files into the visual studio folder and the Windows system folder: It is best to avoid doing this as it makes your project less portable, and makes it much more difficult if you ever need to change which version of the library you are using (old projects might suddenly stop working, etc.)
Instead (apologies for any inconsistencies, I'm basing these instructions on VS2010)...
- put the freeglut folder somewhere else, e.g. C:\dev
- Open your project in Visual Studio
- Open project properties
- There should be a tab for VC++ Directories, here you should add the appropriate include and lib folders, e.g.: C:\dev\freeglut\include and C:\dev\freeglut\lib
- (Almost) Final step is to ensure that the opengl lib file is actually linked during compilation. Still in project properties, expand the linker menu, and open the input tab. For Additional Dependencies add opengl32.lib (you would assume that this would be linked automatically just by adding the include GL/gl.h to your project, but for some reason this doesn't seem to be the case)
At this stage your project should compile OK. To actually run it, you also need to copy the freeglut.dll files into your project folder
This is GLUT installation instruction. Not free glut
First download this 118 KB GLUT package from Here
Extract the downloaded ZIP file and make sure you find the following
glut.h
glut32.lib
glut32.dll
If you have a 32 bits operating system, place glut32.dll to C:\Windows\System32\, if your operating system is 64 bits, place it to 'C:\Windows\SysWOW64\' (to your system directory)
Place glut.h C:\Program Files\Microsoft Visual Studio 12\VC\include\GL\ (NOTE: 12 here refers to your VS version it may be 8 or 10)
If you do not find VC and following directories.. go on create it.
Place glut32.lib to C:\Program Files\Microsoft Visual Studio 12\VC\lib\
Now, open visual Studio and
Under Visual C++, select Empty Project(or your already existing project)
Go to Project -> Properties. Select 'All Configuration' from Configuration dropdown menu on top left corner
Select Linker -> Input
Now right click on "Additional Dependence" found on Right panel and click Edit
now type
opengl32.lib
glu32.lib
glut32.lib
(NOTE: Each .lib in new line)
That's it... You have successfully installed OpenGL.. Go on and run your program.
Same installation instructions aplies to freeglut files with the header files in the GL folder, lib in the lib folder, and dll in the System32 folder.
OpenGL is bundled with Visual Studio. You just need to install GLUT package (freeglut would be fine), which can be found in NuGet.
Open your solution, click TOOLS->NuGet Package Manager->Package Manager Console to open a NuGet console, type Install-Package freeglut.
--
For VS 2013, use nupengl.core package instead.
--
It's 2020 now. Use VCPKG.
For Microsoft Visual Studio 2017 Community GLUT installation -
Download the header, dll's and lib files fro glutdlls37beta (linked in here)
Paste glut.h in C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\{14.11.25503}\include\GL
Create the GL folder if not present already. The {thing} may differ.
Paste glut.lib in C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\{14.11.25503}\lib\x64.
Paste glut32.lib in C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\{14.11.25503}\lib\x86.
The {thing} may differ.
Paste glut32.dll in C:\Windows\System32. Paste glut.dll and glut32.dll in C:\Windows\SysWOW64.
Follow Vishwanath gowda k's answer next.
Go to Project -> Properties(All Configuration option)->Linker -> Input -> Additional Dependencies->edit(down arrow on the right end)
Type->
opengl32.lib
glu32.lib
glut32.lib
Hit Ok->apply.
For an easy and appropriate way of doing this, first download a prepackaged release of freeglut from here. Then read its Readme.txt.
I copied some important parts of that package here:
... Create a folder on your PC which is readable by all users, for example “C:\Program Files\Common Files\MSVC\freeglut\” on a typical Windows system. Copy the “lib\” and “include\” folders from this zip archive to that location ... freeglut DLL can be placed in the same folder as your application...
... Open up the project properties, and select “All Configurations” (this is necessary to ensure our changes are applied for both debug and release builds). Open up the “general” section under “C/C++”, and configure the “include\” folder you created above as an “Additional Include Directory”. If you have more than one GLUT package which contains a “glut.h” file, it’s important to ensure that the freeglut include folder appears above all other GLUT include folders ... Open up the “general” section under “Linker”, and configure the “lib\” folder you created above as an “Additional Library Directory”...
Download the GLUT library. At first step Copy the glut32.dll and paste it in C:\Windows\System32 folder.Second step copy glut.h file and paste it in C:\Program Files\Microsoft Visual Studio\VC\include folder and third step copy glut32.lib and paste it in c:\Program Files\Microsoft Visual Studio\VC\lib folder.
Now you can create visual c++ console application project and include glut.h header file then you can write code for GLUT project.
If you are using 64 bit windows machine then path and glut library may be different but process is similar.
Yes visual studio 2012 express has built in opengl library. the headers are in the folder
C:\Program Files\Windows Kits\8.0\Include\um\gl and the lib files are in folder C:\Program Files\Windows Kits\8.0\Lib\win8\um\x86 & C:\Program Files\Windows Kits\8.0\Lib\win8\um\x64. but the problem is integrating the glut with the existing one..
i downloaded the library from http://www.xmission.com/~nate/glut/glut-3.7.6-bin.zip.. and deployed the files into .....\gl and ....\lib\win8\um\x32 and the dll to %system%/windows folders respectively.. Hope so this will solve the problem...
Download and install Visual C++ Express.
Download and extract "freeglut 2.8.0 MSVC Package" from http://www.transmissionzero.co.uk/software/freeglut-devel/
Installation for Windows 32 bit:
(a) Copy all files from include/GL folder and paste into C:\Program Files\Microsoft SDKs\Windows\v7.0A\Include\gl folder.
(b) Copy all files from lib folder and paste into C:\Program Files\Microsoft SDKs\Windows\v7.0A\Lib folder.
(c) Copy freeglut.dll and paste into C:\windows\system32 folder.
Use NupenGL Nuget package. It is actively updated and works with VS 2013 and 2015, whereas Freeglut Nuget package works with earlier versions of Visual Studio only (as of 10/14/2015).
Also, follow this blog post for easy instructions on working with OpenGL and Glut in VS.
the instructions for Vs2012
To Install FreeGLUT
Download "freeglut 2.8.1 MSVC Package" from http://www.transmissionzero.co.uk/software/freeglut-devel/
Extract the compressed file freeglut-MSVC.zip to a folder freeglut
Inside freeglut folder:
On 32bit versions of windows
copy all files in include/GL folder to C:\Program Files\Windows Kits\8.0\Include\um\gl
copy all files in lib folder to C:\Program Files\Windows Kits\8.0\Lib\win8\um\
(note: Lib\freeglut.lib in a folder goes into x86)
copy freeglut.dll to C:\windows\system32
On 64bit versions of windows:(not 100% sure but try)
copy all files in include/GL folder to C:\Program Files(x86)\Windows Kits\8.0\Include\um\gl
copy all files in lib folder to C:\Program Files(x86)\Windows Kits\8.0\Lib\win8\um\
(note: Lib\freeglut.lib in a folder goes into x86)
copy freeglut.dll to C:\windows\SysWOW64
Create a empty win32 console application c++
Download a package called NupenGL Core from Nuget package manager
(PM->"Install-Package nupengl.core")
except glm everything is configured
create Source.cpp and start working
Happy Coding

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"