可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
I've been getting this error ever since I installed the .NET Framework SDK for 64-bit programming on my Visual C++ 2010 Express compiler. I can't compile even a simple program at all because of this single error I'm getting. My platform is x86. Here is a snap shot if it helps:
I don't know what more to say. I just downloaded this compiler yesterday and it was working fine. I wanted to upgrade from 32-bit programming to 64-bit so I could work with Assembly, so I downloaded this SDK. I searched on Google and even here on Stackoverflow. Google didn't help much, but I found a post here that seemed similar to mine but the answers didn't do much justice. Does anyone know why this error is occurring and how I can get rid of it?
回答1:
Check the VC++ directories, in VS 2010 these can be found in your project properties. Check whether $(WindowsSdkDir)\lib
is included in the directories list, if not, manually add it. If you're building for X64 platform, you should select X64 from the “Platform” ComboBox, and make sure that $(WindowsSdkDir)\lib\x64
is included in the directories list.
回答2:
Change the platform toolset to: "Windows7.1SDK" under project properties->configuration properties->general
回答3:
Make sure you have in VC++ directories (Right click project, Click Property Page),
- Include Directories: $(IncludePath)
- List item Library Directories: $(LibraryPath)
回答4:
For command line (i.e. - makefile) users only:
- When you install VC++ Express, it is 32-bit only. So, things go into C:\Program Files (x86).
- Then, you decide to upgrade to 64-bit capabillities. So, you install the SDK. But it is 64-bit capable. So, things go into C:\Program Files.
You (like me) probably "tuned" your makefile to #1, above, via something like this:
MS_SDK_BASE_DOS := C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A
ENV_SET := LIB="$(MS_SDK_BASE_DOS)\Lib\x64"
But, now, you need to change that tuning to #2, above, like this:
MS_SDK_BASE_DOS := C:\Program Files\Microsoft SDKs\Windows\v7.1
(Don't miss the "v7.0A" to "v7.1" change, as well.)
回答5:
Add lib path of WindowsSdks in project->properties->Configuration Properties->VC++ Directories -> Library directories.
I added following path and error goes::
C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Lib;
My system is Win-7, 64bit, VS 2013, .net framework 4.5
回答6:
I got a similar error, the problem stopped when I checked my "Linker -> Input -> Additional Dependencies" list in the project properties. I was missing a semi colon ";" just before "%(AdditionalDependencies)".
I also had the same entry in twice. You should edit this list separately for Debug and Release.
回答7:
I had a differnt problem on Windows 10 with Visual Studio 2017 but with the same effects. I think my problems came down to VS being installed onto a drive other than "C:\". I solved the problem by Reinstalling Windows 10 SDK
First I had to uninstall the Windows SDK (there were two versions installed). Then ran the executable. Once installed, ran visual studio and it worked fine.
回答8:
gero's solution worked for me.
In Visual Studios 2012, take the following steps.
- Go to Solution Explorer
- Right click on your project
- Go to Properties
- Configuration Properties -> General
- Platform Toolset -> change to Windows7.1SDK
回答9:
If the above solution doesn't work, check to see if you have $(LibraryPath) in Properties->VC++ Directories->Library Directories. If you are missing it, try adding it.
回答10:
OS : Win10, Visual Studio 2015
Solution :
Go to control panel ---> uninstall program ---MSvisual studio ----> change ---->organize = repair
and repair it.
Note that you must connect to internet until repairing finish.
Good luck.
回答11:
Today in Visual Studio 2017 I had the same problem.
The cause in my case turned out to be a bad environment setting in NETFXSDKDir (NETFXSDKDir=C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1
). It needs to be instead NETFXSDKDir=C:\Program Files (x86)\Windows Kits\10\Lib\10.0.10240.0\um\x86
. Specifically, as set in this batch file (my directory actually has 4 different files) for the Command Prompt for VS2017:
%comspec% /k "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Auxiliary\Build\vcvars32.bat"
as I am reluctant to change one of the "as installed" batch files… even more as that batch file calls another yet another:
@call "%~dp0vcvarsall.bat" x86 %*
...instead for my specific C++ command-line app, I simply added the explicit path text: ;C:\Program Files (x86)\Windows Kits\10\Lib\10.0.10240.0\um\x86
for a total string in "Library Directories" like this: $(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86);$(NETFXKitsDir)Lib\um\x86;C:\Program Files (x86)\Windows Kits\10\Lib\10.0.10240.0\um\x86
. (Right click on project, Properties → Configuration Properties → VC++ Directories → Library Directories.) That resolved my "fatal error LNK1104: cannot open file 'kernel32.lib'" error. I found that hint in this GitHub issue.
Note this is reproducible in Visual Studio 2017 Enterprise 2017 Version 15.1 (26403.0) even after successful "repair" install… when creating a new Visual C++ Win32 Console Application and attempting to compile.
In fact, unless a blank application is created, the default template also includes reference to <SDKDDKVer.h>
and with that I get this additional error: Error (active) E1696 cannot open source file "SDKDDKVer.h"
. So I created an empty C++ project.
回答12:
In Visual Studio 2017, I went to Project Properties -> Configuration Properties -> General, Selected All Platforms (1), then chose the dropdown (2) under Windows SDK Version and updated from 10.0.14393.0 to one that was installed (3). For me, that was 10.0.15063.0.
Additional details: This corrected the error in my case because Windows SDK Version helps VS select the correct paths. VC++ Directories -> Library Directories -> Edit -> Macros -> shows that macro $(WindowsSDK_LibraryPath_x86) has a path with the version number selected above.
回答13:
I just met and solved this problem by myself. My problem is a little different. I'm using visual studio on Windows 10. When I create the project, the Target Platform Version
was automatically set to 10.0.15063.0
. But there is no kernel32.lib
for this version of SDK, neither are other necessary header files and lib files. So I modified the Target Platform Version
to 8.1
. And it worked.
Environment:
- Windows 10
- Visual Studio 2015
- Visual C++
Solution:
- Open the project's
Property Page
;
- Navigate to
General
page;
- Modify
Target Platform Version
to the desired target platform (e.g. 8.1
).