I have a C++ project (some sort of a console 32-bit appplication) developed in VS2010, which builds just fine on my PC (Windows 7 32-bit). My PC has Microsoft SDK 7.0A installed, which I think comes bundled with VS2010.
I try to build the project on a build server, which doesn't have any Visual Studio installed - only Microsoft SDK 7.1 is present there.
I try to build the project with the help of msbuild (this will eventually become the task for TeamCity's runner), and on the build server I get following errors (the detailed log is provided):
Project "E:\win\core.sln" on node 1 (default targets).
ValidateSolutionConfiguration:
Building solution configuration "Debug|Win32".
Project "E:\win\core.sln" (1) is building "E:\win\core_unittests.vcxproj" (2) on node 1 (default targets).
Project "E:\win\core_unittests.vcxproj" (2) is building "E:\cpptest\win\cpptest.vcxproj" (3) on node 1 (default targets).
C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.Targets(847,9): warning MSB3644: The reference assemblies for framework ".NETFramework,Version=v4.0" were not found. To resolve this, install the SDK or Targeting Pack for this framework version or retarget your application to a version of the framework for which you have the SDK or Targeting Pack installed. Note that assemblies will be resolved from the Global Assembly Cache (GAC) and will be used in place of reference assemblies. Therefore your assembly may not be correctly targeted for the framework you intend. [E:\cpptest\win\cpptest.vcxproj]
C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppBuild.targets(297,5): warning MSB8003: Could not find WindowsSDKDir variable from the registry. TargetFrameworkVersion or PlatformToolset may be set to an invalid version number. [E:\win\cpptest.vcxproj]
InitializeBuildStatus:
Touching "E:\cpptest\win\..\..\..\out\Debug\cpptest\cpptest.unsuccessfulbuild".
ClCompile:
C:\Program Files\Microsoft Visual Studio 10.0\VC\bin\CL.exe /c /ZI /nologo /W3 /WX- /Od /Oy- /D WIN32 /D _DEBUG /D _LIB /D _UNICODE /D UNICODE /Gm /EHsc /RTC1 /MTd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Fo"E:\cpptest\win\..\..\..\out\Debug\cpptest\\" /Fd"E:\cpptest\win\..\..\..\out\Debug\cpptest\vc100.pdb" /Gd /TP /analyze- /errorReport:queue ../missing.cpp
missing.cpp
e:\cpptest\missing.cpp(36): fatal error C1083: Cannot open include file: 'windows.h': No such file or directory [E:\cpptest\win\cpptest.vcxproj]
I suppose the issue is related to inability of msbuild to find Microsoft SDK, which is installed into "E:\Program Files\Microsoft SDKs\Windows\v7.1"
.
There are few advices how to handle this issue available on the Web:
- Copy part of registry under
HKLM\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.1
toHKCU
(see WindowsSdkDir is not set correctly in Visual Studio 2008?). I didn't try this workaround because as it looks too ugly, and the build process will run with SYSTEM-account credentials. - Pass
WindowsSDKDir
as an extra parameters to MSBuild (as proposed in TeamCity and MSBuild Quirks #1). - Tweaking
VCProjectEngine.dll.config.xml
as proposed in the answer to Include Search Paths in TeamCity build Configurations (I haven't found such file on the PC with Windows SDK). - Change the platform toolset in the project properties as proposed in the answer to WindowsSdkDir is not set correctly in Visual Studio 2010 (I doubt this will help, because my PC doesn't have Windows SDK 7.1 installed).
Actually when compiling with CL.EXE
everything goes fine (because I have INCLUDE
and LIB
variables defined), so it would be a workaround to force msbuild to use/pass the environment variables...
There are similar issues:
- "Differences between building on a machine with VS2010 installed and on a machine with the 7.1 SDK installed" but for .NET projects.
- Erroneous Windows SDK x64 Compilation Warning (building 32-bit project for 64-bit platform).
Anyway has anyone succeeded with building Visual C++ 2010 projects on a PC with Windows SDK installed?