Dani
Dani

Reputation: 15069

error LNK1181: cannot open input file 'kernel32.lib'

I have a project on VS 2012. latest SDK is installed on the WIN 8 x64 computer, the project is targeting WIn32.

I have a clean build in Debug, but when I go to release I get the 1181 LNK error - cannot open input file kernel32.lib.

I have the file on the computer in several location, and in the VC directories there is $(WindowsSdkDir_71A)lib and $(WindowsSdkDir)\lib.

Using process monitor I've tried to rebuild and see where devenv.exe is looking for the file

** UPDATE: In debug it looks in the right place. in release it doesn't look for the sdk, but I see this:

Y:\MyProjectFofler\$(LibraryPath)\kernel32.lib PATH NOT FOUND and also several successful reads from the win8.0 sdk (which should be ok, but the result is the same, and I need it to read from the V7.1A SDK folder...)

What can it be and what might be the solution for this error ?

Thanks.

Upvotes: 2

Views: 7682

Answers (1)

C.D.
C.D.

Reputation: 466

I ran into this using Visual Studio 2017. I was trying to get the Visual Studio project configurations to reference the external library .lib files I wanted. I managed to trigger this error when I removed any reference to the system libraries. I later figured out this can be corrected by including one of their macro values (though you can specify an absolute direct path, but that's probably not the best coding convention and prone to brittleness).

On the Visual Studio project, right-Clicking on the project item in the Solution explorer panel (not the Solution itself, which is the topmost item), then select Properties. From there do the following:

VC++ Directories --> Library Directories : $(ProjectDir)lib; $(LibraryPath)

Note the $(LibraryPath) value will include extra values such as inherited from parents, and from what I can tell this is a verbose option. My folder project contained a folder called 'lib' which is why I had the first value there before the semicolon.

There are other common options I have used to specify the Library Directories value:

$(VC_LibraryPath_x86)
$(WindowsSDK_LibraryPath_x86)
$(NETFXKitsDir)Lib\um\x86

If you look at the section VC++ Directories --> Library Directories, you can click on the entry line and select 'Edit', then you can watch live previews of what Macros values will be evaluated and resolved to. If you need additional or more specialized values, click on the Macros button to look for more options.

Link to image of Visual Studio 2017 Library Directories configuration

Upvotes: 4

Related Questions