January, 2009

January, 2009

  • Care, Share and Grow!

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

    • 15 Comments

    I was a happy man until a few hours back when I was playing with some C, C++ programs built using Visual Studio 2008 on my work and home machines. I could write some program on my workstation, copy the solution to my personal laptop at home and thereby continue from where I left in office. Things  were good until I installed the latest Windows SDK v6.1 on my Vista laptop while trying my hands on Windows PowerShell.

    I realized a day or so later after installing SDK v6.1 that now I could not build my application written in C or C++. I could compile it but not link it during build process from within Visual Studio. Funny though I realized I could not even build a very basic Win32 console application.

    I started getting the following error:

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

    I did something while troubleshooting it and now also started seeing:

    Error spawning 'rc.exe'. Project myProject

    I did check on the Internet and found all sorts of reasoning around this. One thing looked clear that installing the latest SDK v6.1 had caused me all these headaches. Some links suggested rebooting the server, some talked about  low system  memory, some said remove the latest SDK v6.1, and some also suggested to reinstall Visual Studio. But somehow I felt this can be fixed without reinstallation of VS2008 or un-installation of SDK v6.1 or etc etc and etc.

    I opened the cool Process Monitor tool and found the following:

    28836    11:51:31.5538847    devenv.exe    5528    QueryOpen    E:\Program Files\Microsoft Visual Studio 9.0\VC\lib\kernel32.lib    NAME NOT FOUND    
    28837    11:51:31.5539987    devenv.exe    5528    QueryOpen    E:\Program Files\Microsoft Visual Studio 9.0\VC\lib\kernel32.lib    NAME NOT FOUND    
    28839    11:51:31.5542065    devenv.exe    5528    QueryOpen    E:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\lib\kernel32.lib    NAME NOT FOUND    
    28841    11:51:31.5543630    devenv.exe    5528    QueryOpen    E:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\lib\kernel32.lib    NAME NOT FOUND    
    28842    11:51:31.5544705    devenv.exe    5528    QueryOpen    E:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\lib\i386\kernel32.lib    PATH NOT FOUND    
    28844    11:51:31.5545935    devenv.exe    5528    QueryOpen    E:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\lib\i386\kernel32.lib    PATH NOT FOUND    
    28846    11:51:31.5547253    devenv.exe    5528    QueryOpen    D:\Program Files\Microsoft SDKs\Windows\v6.1\lib\kernel32.lib    PATH NOT FOUND    
    28847    11:51:31.5548633    devenv.exe    5528    QueryOpen    D:\Program Files\Microsoft SDKs\Windows\v6.1\lib\kernel32.lib    PATH NOT FOUND    
    28848    11:51:31.5550927    devenv.exe    5528    QueryOpen    D:\Program Files\Microsoft SDKs\Windows\v6.1\lib\kernel32.lib    PATH NOT FOUND    
    28849    11:51:31.5552863    devenv.exe    5528    QueryOpen    D:\Program Files\Microsoft SDKs\Windows\v6.1\lib\kernel32.lib    PATH NOT FOUND    
    28850    11:51:31.5556190    devenv.exe    5528    QueryOpen    E:\Program Files\Microsoft Visual Studio 9.0\kernel32.lib    NAME NOT FOUND    
    28851    11:51:31.5559045    devenv.exe    5528    QueryOpen    E:\Program Files\Microsoft Visual Studio 9.0\kernel32.lib    NAME NOT FOUND    
    28852    11:51:31.5561361    devenv.exe    5528    QueryOpen    E:\Program Files\Microsoft Visual Studio 9.0\lib\kernel32.lib    PATH NOT FOUND    
    28853    11:51:31.5563280    devenv.exe    5528    QueryOpen    E:\Program Files\Microsoft Visual Studio 9.0\lib\kernel32.lib    PATH NOT FOUND    

    It was crystal clear that while trying to link Visual Studio was encountering a file not found kind of error and hence could be the resulting failure.

    ------ Build started: Project: aa, Configuration: Debug Win32 ------
    Linking...
    LINK : fatal error LNK1104: cannot open file 'kernel32.lib'
    Build log was saved at "file://xxxxxxxxxxx\Visual Studio 2008\Projects\myProject\myProject\Debug\BuildLog.htm"
    myProject - 1 error(s), 0 warning(s)
    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

    Similarly rc.exe showed NOT FOUND.

    It looked simple yet intriguing as to why the default path was changed for Visual Studio.

    I realized that the path it was trying to look at for these files did not even exist, lest I could just have copied these files to the corresponding location.

    Looked at the Environment variables from Visual Studio 2008 command prompt and found that WindowsSdkDir environment variable was pointing to D:\Program Files\Microsoft SDKs\Windows\v6.1\ which did not exist.

    Tried changing this to the path where I did find the above files on my box which was pointing to C:\program files\microsoft sdks\windows\v6.0A\ (So yes it pretty much looked like after installing SDK v6.1 my environment variable WindowsSdkDir had changed). Tried logging off/rebooting, no luck.

    Finally figured out that in order to get things back to normal I had to update the following registry key:

    HKEY_CURRENT_USER\SOFTWARE\Microsoft\MicrosoftSDKs\Windows\CurrentInstallFolder

    I changed this value to point to the original location which was C:\Program Files\Microsoft SDKs\Windows\v6.0A\ in my case.

    I wasted a lot of time on this, so thought of sharing with a wider audience.

    bye!

  • Care, Share and Grow!

    New features in SETSPN.EXE on Windows Server 2008

    • 3 Comments

    The version of Setspn.exe that came with Microsoft Windows Server 2000/2003 Support Tools did not have features to detect duplicate SPNs. The new version of Setspn.exe that comes bundled with Windows Server 2008 utilities has some really cool features. For someone dealing with the dreaded Kerberos authentication failure issues on a daily basis like me it's a sigh of relief.

    If you try the following command on the Windows Server 2008 you will see the various new options (or switches) available.

    image

    Notice the modifiers/switches:

    -F = perform the duplicate checking on forestwide level

    -S = add arbitrary SPN after verifying no duplicates exist

    -Q = query for existence of SPN

    -X = search for duplicate SPNs

     

    Searching for duplicate SPNs using Setspn.exe:

    D:\>setspn -X http/www.test.com
    Processing entry 0
    http/www.test.com is registered on these accounts:
        CN=mstest,CN=Users,DC=<some-DC-primary>,DC=<some-DC-secondary>
        CN=<IIS-servername>,OU=Domain Controllers,DC=<some-DC-primary>,DC=<some-DC-secondary> 
    
    found 1 group of duplicate SPNs.
    

    Searching for the existence of an SPN in the domain:

    D:\>setspn -Q http/www.test.com
    CN=<IIS-servername>,OU=Domain Controllers,DC=<some-DC-primary>,DC=<some-DC-secondary>
        http/www.test.com
        ldap/2334590-45566-113f....
        HOST/<IIS-servername>
        HOST/<IIS-servername.<some-DC-primary>.<some-DC-secondary>
        .......
        .......
    CN=mstest,CN=Users,DC=<some-DC-primary>,DC=<some-DC-secondary>
        http/www.test.com 
    
    Existing SPN found!
    

    Adding an arbitrary SPN after verifying no duplicates exist in the domain:

    D:\>setspn -S http/www.test.com <IIS-servername>
    CN=mstest,CN=Users,.<some-DC-primary>.<some-DC-secondary>
        http/www.test.com 
    
    Duplicate SPN found, aborting operation!
    
    

    Adding an arbitrary SPN after verifying no duplicates exist in the forest:

    D:\>setspn -F -S http/www.test.com <IIS-servername>
    Operation will be performed forestwide, it might take a while.
    CN=mstest,CN=Users,DC=<some-DC-primary>,DC=<some-DC-secondary>
        http/www.test.com
    CN=mstest1,CN=Users,DC=<some-DC-primary>,DC=<some-DC-secondary>
        http/www.test.com 
    
    Duplicate SPN found, aborting operation! 
    

    So what does this mean? It means you no longer have to depend upon boggling commands using LDIFDE or your own custom scripts to find out the duplicate SPNs. This is a good news indeed!

    *Prior to this using Windows Server 2000/2003 Support Tools we could use commands using LDIFDE to find duplicate SPNs as below:

    Syntax:

    ldifde -f <filename> -d "<dc=domain-netbiosname,dc=primary-domain>" -l serviceprincipalname -r "(serviceprincipalname=<serviceprincipalname-to-check-for-duplicates>)" -p subtree

    For example, if the domain name is test.abcd.com and the site URL is http//test.abcd.com command should be as shown below:

    ldifde –f C:\log.txt -d "dc=test, dc=abcd, dc=com"-l serviceprincipalname –r "(serviceprinicpalname=http/test.abcd.com)" -p subtree

    With the newer version of Setspn hopefully the dependency on the above command should reduce drastically.

    Till next time,

    Cheers!

Page 1 of 1 (2 items)