Visual Studio 2012 和 2010 - kernel32.lib、windows.h [英] Visual Studio 2012 alongside 2010 - kernel32.lib, windows.h

查看:22
本文介绍了Visual Studio 2012 和 2010 - kernel32.lib、windows.h的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚安装了 Visual Studio 2012 和 Visual Studio 2010.问题是我无法将简单的项目从 2010 年转换到 2012 年 - 它们无法链接到 kernel32.lib 等文件或包含 windows 等文件.H.我的系统也安装了 Windows SDK 7.1.

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.

我尝试在我的 x86 和 x64 用户平台上使用属性管理器(因为我在那里添加了适当的 $(DXSDK_DIR) 引用),结果却是混合的——有时它可以正常工作,有时它可以编译但没有链接,其他时候它只是停在 windows.h

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

例如,目前我得到

1>LINK : fatal error LNK1104: cannot open file 'kernel32.lib'

1>Source.cpp(2): fatal error C1083: Cannot open include file: 'windows.h': No such file or directory

(取决于是否包含windows.h")仅在 x64 中使用简单的hello world"类型程序.

(depending on the inclusion or not of "windows.h") with a simple "hello world" type program only in x64.

Active(Debug)/Active(x64) 的项目属性中 ->VC++ 目录 ->包含目录 我现在可以看到 $(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSDK_IncludePath);$(DXSDK_DIR)Include.如果我展开该输入框并单击编辑",我会看到:

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

虽然我的平台工具集 v110 windows.h 位于 c:\Program Files (x86)\Windows Kits\8.0\Include\um\Windows.h(所以应该没有问题).如果我选择 Windows SDK 7.1 作为平台工具集,则一切正常.

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.

除了格式化和重新安装 Windows 之外还有其他解决方案吗?

Any solution besides formatting and reinstalling Windows?

L.E.如果我用系统内的绝对路径替换 $(variable) 目录,一切正常.我不明白我为什么要这样做,因为我也在与其他人分享这个项目.

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

问题好像是在安装VS2012和VS2010时,VS2012的配置无法正常工作.

The problem seems to be that when VS2012 and VS2010 are installed, the configuration for VS2012 does not work correctly.

修复方法是编辑 %home%\AppData\Local\Microsoft\MSBuild\v4.0 中的 props 文件.

The fix is to edit the props files in %home%\AppData\Local\Microsoft\MSBuild\v4.0.

这些是对我有用的文件,使用 SDK v8.1.

These are the files that worked for me, using SDK v8.1.

第一个用于 32 位构建的 Microsoft.Cpp.Win32.user.props:

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>

现在用于 64 位构建的 Microsoft.Cpp.x64.user.props:

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.

这篇关于Visual Studio 2012 和 2010 - kernel32.lib、windows.h的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆