Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

error cannot open file 'kernel32.lib'

I have installed VS2013 and VS2015 on Windows 7.

I have an existing C++ Dll project that was building fine but now all of a sudden it wont build using VS2015 and gives me the error:

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

From this post: fatal error LNK1104: cannot open file 'kernel32.lib' I went looking for the kernel32.lib file and it is located here:

C:\Program Files (x86)\Windows Kits\8.1\Lib\winv6.3\um\x86

When I go to my Projects Properties-->Linker-->Input and select Macros I see that this path is indeed there:

enter image description here

My Platform Toolset is set to Visual Studio 2013 - Windows XP (v120_xp) which is what it always has been set to.

Why has my Project all of a sudden stopped building? What could have gone wrong?

like image 795
Harry Boy Avatar asked Sep 15 '16 15:09

Harry Boy


3 Answers

I had this similar problem today with Visual Studio 2013 when I changed my VC++ Directories:

Project->Properties->VC++ Directories: Include Directories

like image 116
João Luis Avatar answered Nov 02 '22 23:11

João Luis


If the cause is some plug-in/extension that changes your props files, it may in consequence change the "Visual C++ Directories" settings of your project.

So, the solution that worked for me is described on my own answer Can't compile 64 bits Visual Studio 2010 projects, which I fully transcribe to here:

After I asked a colleague for help, we noticed, that even getting clean builds of the projects from TFS, with overwrite option, the Project's Configuration Properties > VC++ Directories on my computer were always different from other computers.

Searching more we found the solution on the last post of Reset include/lib path, which I will fully transcribe:

use "del %HOMEPATH%\AppData\Local\Microsoft\MSBuild\v4.0\Microsoft.Cpp.Win32.user.props" is not always the right way. Better use "del %USERPROFILE%\AppData\Local\Microsoft\MSBuild\v4.0\Microsoft.Cpp.Win32.user.props" where the application data folder is normally placed in.

Then I've looked inside the contents of Microsoft.Cpp.x64.user.props and I've seen that there were things added by Visual Leaks Detector. Which is reasonable, as one month before, I did a memory leak analysis using VLD.

So, I deleted the file and now everything compiles fine at 64bits!

like image 21
sergiol Avatar answered Nov 03 '22 01:11

sergiol


I had to install the Visual C++ for Desktop Development.

Open Visual Studio Installer and go to Installed tab. Click on the Change Button on your installed Visual Studio Community Edition. -> On the Workloads Tab there should be a option Desktop Development with C++. Activate that option and modify the changes.

Afterwards it was working for me.

like image 3
Marcel R Avatar answered Nov 03 '22 00:11

Marcel R