Getting LINK : fatal error LNK1104: cannot open file 'kernel32.lib' in V C++2008 compiler


i have just started on the basics of C++ and have already hit a snag with Visual C++ Command line compiler

i recieve this error LINK : fatal error LNK1104: cannot open file 'kernel32.lib' when trying to compile using the command line

this has worked fine on another PC running Vista and i have done a search and have found that i do have the kernel32.lib file on the PC in the Microsoft SDK folder in Program Files

any help appreciated


Who is Participating?
Mortaza DoulatyConnect With a Mentor Commented:
If you're using command prompt version, then the arguments should be something like this:
/OUT:"c:\YouExeFile.exe" /NOLOGO /MANIFEST /MANIFESTFILE:"YourManifestFile.exe.intermediate.manifest" /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /DEBUG /PDB:"YourPDBFile.pdb" /DYNAMICBASE /NXCOMPAT /MACHINE:X86 /ERRORREPORT:PROMPT kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib
Mortaza DoulatyCommented:
Have a look at your linker setting.
It sounds like it can not link with kernel32.lib
Mortaza DoulatyCommented:
Check the file "corewin_express.vsprops" which is in
C:\Program Files\Microsoft Visual Studio 9.0\VC\VCProjectDefaults
It has a line with beginning with "AdditionalDependencies"

It should be something like this:
AdditionalDependencies="kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib"/>

It must have kernel32.lib
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

mattyboy711Author Commented:
thanks for your replies, the corewin file has kernel32.lib included in it

any other ideas?
Mortaza DoulatyCommented:
No idea!

In an empty project, try to have this code, the compile it and see errors:

#pragma comment (lib, "kernel32.lib")
#include <windows.h>
int WINAPI WinMain(HINSTANCE hInstance,
    HINSTANCE hPrevInstance,
    LPSTR lpCmdLine,
    int nCmdShow
	MessageBox(NULL, "This is a test.","Test", MB_OK);

Open in new window

mattyboy711Author Commented:
test.cpp(5) : fatal error C1083: Cannot open include file: 'windows.h': No such
file or directory

is the error i try and get with this project, have tried fresh install of VC++ aswell, think it might just be time to bite the bullet and just use on my home PC rather than my work PC aswell

thanks fro your help
Mortaza DoulatyCommented:
How do you compile your project?
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.