I'm just trying to compile a simple Hello World program in the latest Visual Studio but when I hit compile I get the following message:
'LINK : fatal error LNK1104: cannot open file 'kernel32.lib'
I'm pretty new at Visual Studio and C++, how do I fix this problem? Any help would be greatly appreciated, thank you.
Sounds like you didn't start off with the right flavor project. Or, you did start off with the right project, but then grew your scope to using facilities your project wasn't configured for.
It can most likely be fixed manually by linker parms and switches, but it easier for you (and me!) to just start over. I suspect you haven't invested too much time in Hello World, so perhaps you can just cut and paste into the new project.
Actually, I'm not sure it's the right flavour of project that is the problem here.
I would hazard a guess that the real problem here is that the linker is not able to find system libraries - perhaps the lib file is not actually supplied with the Visual Studio, and you have to install the Windows SDK (aka Platform SDK) to get the .lib file for Kernel32.dll?
For Visual Studio Express, you indeed have to install the Platform SDK to get kernel32.lib. But a simple console application shouldn't have a need to link against it.
Indeed, as long as the functions used are standard C library functions, it shouldn't need any extra libraries. But if you want to use some specific Windows functions, then you may need kernel32.lib. For example CreateProcess() is a kernel32.lib function. (There are more than a 1000 functions in Kernel32.lib)
Originally Posted by CornedBee
Every application, console or not, links against kernel32.dll.
But perhaps the C/C++ runtime links against kernel32.dll too?
The runtime links against kernel32.dll, but it's pre-built, so you don't need kernel32.lib.
A pure console application should not link against anything but msvcrtxx.dll and (in C++) msvcppxx.dll (or something like that).