Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
449 views
in Technique[技术] by (71.8m points)

c++ - Visual Studio error: LNK1104: cannot open file 'kernel32.lib' - only in WP8 projects / Win32 builds

I ran into this problem recently (few days ago everything was working fine): Visual Studio 2012 started to refuse to build native WP8 projects.

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:

1>------ Build started: Project: PhoneDirect3DApp, Configuration: Debug ARM ------
.......

Build Summary
-------------
00:11.742 - Success - Debug ARM - PhoneDirect3DAppPhoneDirect3DApp.vcxproj

but Win32 does not:

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

My standard (native C++/Win32) projects also work as expected (in both Win32 and x64 platform targets).

Project configuration: (in both platforms)

Linker::Input:

d3d11.lib;%(AdditionalDependencies)

Linker::Ignore:

ole32.lib;%(IgnoreSpecificDefaultLibraries)

VC++ Directories:

Microsoft.ARM.Cpp.User:

$(WP80ToolSetPath)libarm;$(WindowsSDK_LibraryPath_ARM);

Microsoft.Win32.Cpp.User:

$(VCInstallDir)lib;$(VCInstallDir)atlmfclib;$(WP80ToolSetPath)libx86;$(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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Finally, I have found the reason of my problems: as I suspected, internal Visual Studio configuration has been broken.

I did all standard steps, that can be performed in case of LNK1104, however:

- 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

C:Program Files (x86)Windows Phone Kits8.0

instead of

C:Program Files (x86)Windows Kits8.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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...