Solved

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

Posted on 2009-04-15
8
3,323 Views
Last Modified: 2012-05-06
Hi

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

thanks

Matt
0
Comment
Question by:mattyboy711
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 2
8 Comments
 
LVL 12

Expert Comment

by:Mortaza Doulaty
ID: 24178875
Have a look at your linker setting.
It sounds like it can not link with kernel32.lib
0
 
LVL 12

Expert Comment

by:Mortaza Doulaty
ID: 24178883
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
0
 

Author Comment

by:mattyboy711
ID: 24194085
Hi
thanks for your replies, the corewin file has kernel32.lib included in it

any other ideas?
0
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 12

Expert Comment

by:Mortaza Doulaty
ID: 24201764
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);
 
	return ERROR_SUCCESS;
}

Open in new window

0
 

Author Comment

by:mattyboy711
ID: 24203015
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
0
 
LVL 12

Expert Comment

by:Mortaza Doulaty
ID: 24203130
How do you compile your project?
0
 
LVL 12

Accepted Solution

by:
Mortaza Doulaty earned 500 total points
ID: 24203141
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
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
need some help with Editbox 11 111
.NET Best Practice for SQLclient Connection String - Persist Security Info 4 318
template declaration 35 143
Auto build a project upon execution 20 90
The following diagram presents a diamond class hierarchy: As depicted, diamond inheritance denotes when two classes (e.g., CDerived1 and CDerived2), separately extending a common base class (e.g., CBase), are sub classed simultaneously by a fourt…
In Easy String Encryption Using CryptoAPI in C++ (http://www.experts-exchange.com/viewArticle.jsp?aid=1193) I described how to encrypt text and recommended that the encrypted text be stored as a series of hexadecimal digits -- because cyphertext may…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question