Thread: kernel32.lib ERROR in VS 2008

  1. #1
    Registered User
    Join Date
    Jan 2012
    Posts
    4

    kernel32.lib ERROR in VS 2008

    Hi,

    My first post .

    I am trying to compile a C program in VS 2008. When I try to compile my simple "Hello World" program in C I get the following error.

    The program I wrote was :

    Code:
    
    
    Code:
    #include <stdio.h>
    main()
    {
        printf("hello, world \n");
    }


    1>Linking...
    1>LINK : fatal error LNK1104: cannot open file 'kernel32.lib'



    I created an empty general application, then created a simple C program to print "HELLO WORLD".


    Thanks,
    jharohitkumar05

  2. #2
    Registered User
    Join Date
    Mar 2011
    Posts
    546
    looks to me like your visual studio is not installed properly. kernel32.lib is one of the default linker inputs but the linker isn't finding it. the paths are controlled in tools->options->projects and solutions->vc++ directories. however with a proper install those will be correct.

    btw, you should declare main as int main(void) and return 0 at the end of your main routine. buts thats not the linker problem.

  3. #3
    Registered User
    Join Date
    Jan 2012
    Posts
    4

    Talking Any patch to fix the kernel32.lib ERROR in VS 2008 ???

    Quote Originally Posted by dmh2000 View Post
    looks to me like your visual studio is not installed properly. kernel32.lib is one of the default linker inputs but the linker isn't finding it. the paths are controlled in tools->options->projects and solutions->vc++ directories. however with a proper install those will be correct.

    btw, you should declare main as int main(void) and return 0 at the end of your main routine. buts thats not the linker problem.
    hi dmh2000

    Thanks a lot for the prompt and useful reply. I would like to inform you that I am accessing VS 2008 at my workplace where we have to raise a lot of requests before installing a new product which will consume a hell lot of time. Is there any patch available by which this problem can be fixed or any other way to overcome this problem?
    btw thanks for letting me know how to correctly incorporate main(). I will take care of that.


    Thanks and Regards
    Rohit Kumar Jha

  4. #4
    Registered User
    Join Date
    May 2009
    Posts
    4,183
    Can you uninstall and then reinstall VS 2008?

    If not, then assuming the problem is a bad install there is little you can do.

    I do NOT use VS enough to know if these symptoms mean a bad install.

    Tim S.

  5. #5
    Registered User
    Join Date
    Mar 2011
    Posts
    546
    1. search your computer for kernel32.lib. it has to be somewhere on there. it should be in either "\program files\microsoft visual studio 9.0" or "\Program Files \Microsoft SDKs\Windows" (in the x86 program files for 64 bit windows)
    2. in your project options, add the path to that file (not including the file name) to linker options - additional library paths

    if kernel32.lib is nowhere to be found, then you have to reinstall VC2008

  6. #6
    Registered User
    Join Date
    Jan 2012
    Posts
    4

    New error crops up :(

    @stahta01 : Thanks a lot for your kind help.I am afraid that I wont be able to resinstall it because it requires a lot of permissions from Admin since I am accessing VS 2008 at my workplace

    @dmh2000 : Thanks a lot for the help. I found kernel32.lib at C:\Program Files\Microsoft SDKs\Windows\v5.0\Lib\IA64 and added its at the pathtools->options->projects and solutions->vc++ directories in Library Files .

    But now when i press F5 a new error crops up :

    1>1_hello_world.obj : error LNK2019: unresolved external symbol __imp__printf referenced in function _main
    1>1_hello_world.obj : error LNK2019: unresolved external symbol __RTC_CheckEsp referenced in function _main
    1>1_hello_world.obj : error LNK2001: unresolved external symbol __RTC_Shutdown
    1>1_hello_world.obj : error LNK2001: unresolved external symbol __RTC_InitBase
    1>LINK : error LNK2001: unresolved external symbol _mainCRTStartup
    1>C:\Documents and Settings\jrohit\My Documents\Visual Studio 2008\Projects\hello_world\Debug\hello_world.exe : fatal error LNK1120: 5 unresolved externals


    My program looks like this :

    Code:
    #include <stdio.h>
    int main()
    {
        printf("hello, world \n");
        return 0;
    }



    What can be the reason for such an error? I hope with these starting glitches cleared I would be able to sail smoothly with much complex programs...But till then please bear with my stupid doubts...

    Thanks

  7. #7
    Registered User
    Join Date
    May 2009
    Posts
    4,183
    You likely need "C:\Program Files\Microsoft Visual Studio 9.0\VC\lib" added to your library search folders. (directories in Library Files)
    Guess from Code::Blocks user, I do not use MS VS much.

    Tim S.

  8. #8
    Registered User
    Join Date
    Jan 2012
    Posts
    4

    @stahta01

    @stahta01 : I am afraid but this does not solve my problem either Rather, the number of errors increase.

  9. #9
    Registered User
    Join Date
    May 2009
    Posts
    4,183
    FYI: IA64 means the Intel 64 bit machine, they are very rare!

    Are you on a 64 bit or 32 bit PC?

    "My Computer" right click properties gives info.

    If 32 bit, remove the IA64 from the path to get "C:\Program Files\Microsoft SDKs\Windows\v5.0\Lib"
    Note: v5.0 is very old.

    Tim S.
    Last edited by stahta01; 01-06-2012 at 09:52 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. VC 2008 linker error
    By Holmes in forum C++ Programming
    Replies: 19
    Last Post: 05-19-2011, 02:28 AM
  2. LINK2001 Error? VS 2008 C++
    By kazzal in forum C++ Programming
    Replies: 3
    Last Post: 11-07-2009, 03:23 AM
  3. Linking error. VC++ 2008.
    By Raigne in forum C++ Programming
    Replies: 6
    Last Post: 04-21-2008, 09:49 PM
  4. kernel32.dll
    By Fluffy_Bunny in forum C++ Programming
    Replies: 7
    Last Post: 07-15-2002, 01:59 AM
  5. .. caused an error in KERNEL32.DLL
    By Unregistered in forum C Programming
    Replies: 9
    Last Post: 05-15-2002, 01:52 PM