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

Hello, so I started in on section 2 of Unreal Engine C++ Developer: Learn C++ and Make Video Games and it wanted us to run a simple program such as the picture you see below

After running the program it sends me an error such as : LINK : fatal error LNK1104: cannot open file ‘kernel32.lib’. After spending multiple hours on the web looking at solutions I still cannot find the cause of this error. Here are screenshots of everything I installed:

I also doubled checked to make sure everything was up to date and it is. Any help would be useful, thank you.

In the indivdual components tab, do you have the Universal C Runtime installed?

Yes, I have Universal C Runtime installed. Here is a list of all the individual components that are installed:

  • .NET Framework 4.6 targeting pack
  • NuGet package manager
  • C# and Visual Basic Roslyn compilers
  • C++ 2019 Redistributable Update
  • MSVC v142 - VS 2019 C++ x64/x86 build tools (v14.26)
  • C++ AddressSanitizer (Experimental)
  • C++ profiling tools
  • C# and Visual Basic
  • C++ core features
  • IntelliCode
  • Graphics debugger and GPU profiler for DirectX
  • Visual Studio SDK
  • Windows 10 SDK (10.0.16299.0)
  • Windows Universal C Runtime

Could you try restarting your PC and/or repairing Visual Studio?

Just tried it and it gives the same error ( LINK : fatal error LNK1104: cannot open file ‘kernel32.lib’ ). I have even uninstalled and reinstalled the programs and it still does not effect it.

I have done some coding in other languages such as python and java, and I read that it can sometimes effect the path of finding ‘kernel32.lib’. However I am not really sure how to check that path or even if I did find the path I would not know what to change.

Before checking if other things might be affecting it could you see if you actually do have it?

By default It should be in

C:\Program Files (x86)\Windows Kits\10\Lib\{exact version number}\um\x64

Also in the x86 directory.

Just checked both file locations (x64 and x86) and they both have kernel32.lib

Here’s a screenshot of the files in their locations:

x64:

x86:

Yup. I can confirm this is 100% strange.

In the developer command prompt do you see any Windows Kits path come up with?

echo %LIBPPATH%

The only response I get is %LIBPPATH%

Well that’s not right. So could you show your environment variables?

These are the variable I have:

Oh! my friend pointed out the %LIBPPATH% had an extra P, so when i removed it, it gave a response.

Here’s the response it got:
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.26.28801\lib\x86;
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.26.28801\lib\x86\store\references;
C:\Windows\Microsoft.NET\Framework\v4.0.30319;

Having the same issue …
Actually, I don’t have kernel32.lib in the path that %libpath% is pointing to … What step of the installation did I mess up?

Ha, I missed it too.

Yeah so that’s missing the library path for the Windows SDK. Did you try just uninstalling that component before or just the entire lot?

I tried uninstalling the entire lot

Could you try just the Windows SDK(s)? Might weirdly solve it :man_shrugging: ?

Tried it and It didn’t change anything. I even tried installing a different version, uninstalling visual studios and windows SDK and then reinstalling SDK first, and running the install program as an administrator, all giving me the same result of not working.

Are you able to use Visual Studio Community instead?

Looking up on how to use it, not really sure how to run things in it yet but i’ll let you know if it works

Privacy & Terms