C++ Visual Studio 错误:LNK1104:无法打开文件 'kernel32.lib' - 仅在 WP8 项目/Win32 版本中
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21056470/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Visual Studio error: LNK1104: cannot open file 'kernel32.lib' - only in WP8 projects / Win32 builds
提问by Mateusz Grzejek
I ran into this problem recently (few days ago everything was working fine): Visual Studio 2012 started to refuse to build native WP8 projects.
我最近遇到了这个问题(几天前一切正常):Visual Studio 2012 开始拒绝构建原生 WP8 项目。
Today, I created new solution from template 'Windows Phone Direct3D App (Native Only)' to check if my newly created DLLs will be properly supported on WP. I tried to compile this project, first without any changes or additional references - pure code generated by VS. However, it failed with given error. I know very well what does it mean and what could be the possible reason, but I can't understand, hovewer, where does it come from in this case. Weird thing: this only happens in 'Win32' configuration, ARM compiles fine:
今天,我从模板“Windows Phone Direct3D App (Native Only)”创建了新的解决方案,以检查我新创建的 DLL 是否能在 WP 上得到正确支持。我试图编译这个项目,首先没有任何更改或额外的引用 - VS 生成的纯代码。但是,它因给定错误而失败。我非常清楚这意味着什么以及可能的原因是什么,但我无法理解,但是,在这种情况下它来自哪里。奇怪的事情:这只发生在“Win32”配置中,ARM 编译得很好:
1>------ Build started: Project: PhoneDirect3DApp, Configuration: Debug ARM ------
.......
Build Summary
-------------
00:11.742 - Success - Debug ARM - PhoneDirect3DApp\PhoneDirect3DApp.vcxproj
but Win32 does not:
但 Win32 没有:
1>------ Build started: Project: PhoneDirect3DApp, Configuration: Debug Win32 ------
.......
1>LINK : fatal error LNK1104: cannot open file 'kernel32.lib'
Build Summary
-------------
00:09.725 - Failed - Debug Win32 - PhoneDirect3DApp\PhoneDirect3DApp.vcxproj
My standard (native C++/Win32) projects also work as expected (in both Win32 and x64 platform targets).
我的标准(本机 C++/Win32)项目也按预期工作(在 Win32 和 x64 平台目标中)。
Project configuration: (in both platforms)
项目配置:(在两个平台中)
Linker::Input:
链接器::输入:
d3d11.lib;%(AdditionalDependencies)
Linker::Ignore:
链接器::忽略:
ole32.lib;%(IgnoreSpecificDefaultLibraries)
VC++ Directories:
VC++ 目录:
Microsoft.ARM.Cpp.User:
Microsoft.ARM.Cpp.User:
$(WP80ToolSetPath)lib\arm;$(WindowsSDK_LibraryPath_ARM);
Microsoft.Win32.Cpp.User:
Microsoft.Win32.Cpp.User:
$(VCInstallDir)lib;$(VCInstallDir)atlmfc\lib;$(WP80ToolSetPath)lib\x86;$(WindowsSDK_LibraryPath_x86)
Any ideas what else could be wrong or configured incorrectly? I'm running out of ideas, I have never seen something like this before.
任何想法还有什么可能是错误的或配置不正确?我的想法快用完了,我以前从未见过这样的事情。
By the way, I have noticed one more change: when I was trying to compile WP8 projects in ARM configurtion before, there was always an error, saying "building ARM application on desktop is not supported" (or something like that). Now ARM compiles with no problem. Is it normal?
顺便说一下,我还注意到一个变化:之前我尝试在 ARM 配置中编译 WP8 项目时,总是出现错误,说“不支持在桌面上构建 ARM 应用程序”(或类似的内容)。现在ARM编译没有问题。正常吗?
回答by Mateusz Grzejek
Finally, I have found the reason of my problems: as I suspected, internal Visual Studio configuration has been broken.
终于,我找到了我的问题的原因:正如我所怀疑的那样,内部Visual Studio配置被破坏了。
I did all standard steps, that can be performed in case of LNK1104, however:
我做了所有标准步骤,可以在 LNK1104 的情况下执行,但是:
- kernel32.lib was in valid location - all include and library directories was correct - standard *.props files were attached to each project
However, the cause was lying elsewhere.
然而,原因在别处。
All paths are defined using standard macros. One of them is $(WindowsSDK80Path), which is used to build include/library paths. On my system, this macro was defined as
所有路径都使用标准宏定义。其中之一是 $(WindowsSDK80Path),用于构建包含/库路径。在我的系统上,这个宏被定义为
C:\Program Files (x86)\Windows Phone Kits.0
instead of
代替
C:\Program Files (x86)\Windows Kits.0
And that's it. I do not know, when or how, this problem arosed. Visual Studio repair via orginal installer was sufficient method to fix everything. All projects compile now without any problems.
就是这样。我不知道这个问题是何时或如何出现的。通过原始安装程序修复 Visual Studio 足以解决所有问题。所有项目现在编译没有任何问题。