locked
fatal error LNK1104:cannot open file 'user32.lib'

    Question

  •  

    hallo,

    i got this error after building my source code:  fatal error LNK1104:cannot open file 'user32.lib'

    i've seen a similar thread but i still can't solve the problem. I folowed all the instructions from the video on installing the PSDK. What can i do?? Pliz help!!

     

    Thursday, February 02, 2006 8:09 PM

Answers

  • 1. Have you installed the Microsoft Platform SDK?

    2. Have you added "...\Microsoft Platform SDK\Lib" to the list of Lib directories under Tools->Options->VC++ directories->Library files?
    Thursday, February 02, 2006 8:28 PM
  • Take a look at http://msdn.microsoft.com/vstudio/express/visualc/usingpsdk/ for additional ways.

    Hope this helps!

    Thanks,
    Ayman Shoukry
    VC++ Team
    Thursday, February 02, 2006 8:30 PM
  • Actually, nevermind on this.  All it took to fix was a visit to windowsupdate to get a fix for .net, and now the win32 apps will build without linking errors.  So no replies are necessary anymore.

    Thanks

    Chris S.

    Tuesday, July 11, 2006 10:12 PM

All replies

  • 1. Have you installed the Microsoft Platform SDK?

    2. Have you added "...\Microsoft Platform SDK\Lib" to the list of Lib directories under Tools->Options->VC++ directories->Library files?
    Thursday, February 02, 2006 8:28 PM
  • Take a look at http://msdn.microsoft.com/vstudio/express/visualc/usingpsdk/ for additional ways.

    Hope this helps!

    Thanks,
    Ayman Shoukry
    VC++ Team
    Thursday, February 02, 2006 8:30 PM
  • Thanx for the help! Its now working fine!
    Thursday, February 02, 2006 11:42 PM
  • I have had the same problem. I attempted to add these file paths according to the instructions but to no avail.  Do I have to include the $ symbol before the path name to make it work?  I have tried just about everything else...

    I have the platform sdk, and I tried both ways to add the file paths, by going into options, and by manually editing the config file to reflect the paths. Yet each time I still get the same error:

    ------ Build started: Project: nametesting, Configuration: Debug Win32 ------

    Linking...

    LINK : fatal error LNK1104: cannot open file 'user32.lib'

    Build log was saved at "file://c:\Documents and Settings\Chris\My Documents\Visual Studio 2005\Projects\nametesting\nametesting\Debug\BuildLog.htm"

    nametesting - 1 error(s), 0 warning(s)

    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

    Can anyone help?  Maybe I am not doing this right.  If you could send me a printscreen to make sure I have done the same thing you've done, that may allow me to see what I have done wrong.

    Chris S.

     

     

    Tuesday, July 11, 2006 1:44 AM
  • Actually, nevermind on this.  All it took to fix was a visit to windowsupdate to get a fix for .net, and now the win32 apps will build without linking errors.  So no replies are necessary anymore.

    Thanks

    Chris S.

    Tuesday, July 11, 2006 10:12 PM
  • Can you send me the link you got the update from or exact update name? I am running into same trouble as you were. Thank you.
    Tuesday, April 03, 2007 3:32 PM
  • I'm having the same problem, but it's made worse because I am using the Windows SDK and most of the instructions are for the older Platform SDK.  A key difference is that the Windows SDK and Platform SDK packages seem to have several changes in their paths.  I followed the instructions to install the Windows SDK into Visual Studio C++ Express, and the paths seem to be in the correct places. 

    The library path in Tools->Options->Projects and Solutions->VC++ Paths is set to
    C:\Program Files\Microsoft SDKs\Windows\v6.0\Lib

    There seem to be multiple Lib directories, but that is the one that the Microsoft Windows SDK installed.

    My setup is:
    Windows Vista Ultimate x64 (I am compiling for x86 win32 though)
    Visual Studio Express C++
    Windows SDK (downloaded yesterday, used the web install version)
    started VC++, closed it, ran Microsoft Windows SDK->Visual Studio Registration->Integrate Windows SDK with Visual Studio 2005, restarted Visual Studio Express.  No luck.

    Still recieve "fatal error LNK1104:cannot open file 'user32.lib'"

    Rob Redbeard
    Wednesday, October 31, 2007 6:56 AM
  • I think that the path should be:

     

    C:\program files\microsoft sdks\windows\v6.0a\lib

     

     

    Wednesday, October 31, 2007 7:29 PM
  •  

    C:\program files\microsoft sdks\windows\v6.0a\lib  does not exist on my system, the path C:\program files\microsoft sdks\windows\v6.0\lib does though.

     

    Inside the C:\program files\microsoft sdks\windows\v6.0\lib location there are four objects.  \x64 \x86 faxcomex.tlb  and WiaScr.tlb.  The \x86 directory is EMPTY except for wsdapi.lib.  The x64 directory contains all the libraries.  Do I need to specify down to this directory?  Is this okay to link against? My system is 64bit Vista...

     

    Cheers,

    Rob RedBeard

    • Proposed as answer by Istrebitel Thursday, October 07, 2010 8:24 AM
    Wednesday, October 31, 2007 11:44 PM
  •  

    So *after* I posted, I thought about it some more and added C:\Program Files\Microsoft SDKs\Windows\v6.0\Lib\x64 to my library paths.  Viola! no more cannot open file *.lib ...

     

    But now the compile breaks with 33 unresolved symbols.   Just to clarify -- the project I'm compiling is absolutely nothing more than the project created by the Win32 Console Application --> Windows Application noatl Wizard.  I have not modified the code in anyway;

     

    Compiling...
    stdafx.cpp
    Compiling...
    testwin32app.cpp
    Compiling resources...
    Microsoft (R) Windows (R) Resource Compiler Version 6.0.5724.0
    Copyright (C) Microsoft Corporation.  All rights reserved.
    Linking...
    testwin32app.obj : error LNK2001: unresolved external symbol __imp__CreateWindowExW@48
    testwin32app.obj : error LNK2001: unresolved external symbol __imp__ShowWindow@8
    testwin32app.obj : error LNK2001: unresolved external symbol __imp__UpdateWindow@4
    testwin32app.obj : error LNK2001: unresolved external symbol __imp__DialogBoxParamW@20
    testwin32app.obj : error LNK2001: unresolved external symbol __imp__DestroyWindow@4
    testwin32app.obj : error LNK2001: unresolved external symbol __imp__DefWindowProcW@16
    testwin32app.obj : error LNK2001: unresolved external symbol __imp__BeginPaint@8
    testwin32app.obj : error LNK2001: unresolved external symbol __imp__EndPaint@8
    testwin32app.obj : error LNK2001: unresolved external symbol __imp__PostQuitMessage@4
    testwin32app.obj : error LNK2001: unresolved external symbol __imp__EndDialog@8
    testwin32app.obj : error LNK2001: unresolved external symbol __imp__LoadStringW@16
    testwin32app.obj : error LNK2001: unresolved external symbol __imp__LoadAcceleratorsW@8
    testwin32app.obj : error LNK2001: unresolved external symbol __imp__GetMessageW@16
    testwin32app.obj : error LNK2001: unresolved external symbol __imp__TranslateAcceleratorW@12
    testwin32app.obj : error LNK2001: unresolved external symbol __imp__TranslateMessage@4
    testwin32app.obj : error LNK2001: unresolved external symbol __imp__DispatchMessageW@4
    testwin32app.obj : error LNK2001: unresolved external symbol __imp__LoadIconW@8
    testwin32app.obj : error LNK2001: unresolved external symbol __imp__LoadCursorW@8
    testwin32app.obj : error LNK2001: unresolved external symbol __imp__RegisterClassExW@4
    MSVCRT.lib(wcrtexew.obj) : error LNK2001: unresolved external symbol __imp__InterlockedExchange@8
    MSVCRT.lib(wcrtexew.obj) : error LNK2001: unresolved external symbol __imp__Sleep@4
    MSVCRT.lib(wcrtexew.obj) : error LNK2001: unresolved external symbol __imp__InterlockedCompareExchange@12
    MSVCRT.lib(wcrtexew.obj) : error LNK2001: unresolved external symbol __imp__GetStartupInfoW@4
    MSVCRT.lib(gs_report.obj) : error LNK2001: unresolved external symbol __imp__TerminateProcess@8
    MSVCRT.lib(gs_report.obj) : error LNK2001: unresolved external symbol __imp__GetCurrentProcess@0
    MSVCRT.lib(gs_report.obj) : error LNK2001: unresolved external symbol __imp__UnhandledExceptionFilter@4
    MSVCRT.lib(gs_report.obj) : error LNK2001: unresolved external symbol __imp__SetUnhandledExceptionFilter@4
    MSVCRT.lib(unhandld.obj) : error LNK2001: unresolved external symbol __imp__SetUnhandledExceptionFilter@4
    MSVCRT.lib(gs_report.obj) : error LNK2001: unresolved external symbol __imp__IsDebuggerPresent@0
    MSVCRT.lib(gs_support.obj) : error LNK2001: unresolved external symbol __imp__QueryPerformanceCounter@4
    MSVCRT.lib(gs_support.obj) : error LNK2001: unresolved external symbol __imp__GetTickCount@0
    MSVCRT.lib(gs_support.obj) : error LNK2001: unresolved external symbol __imp__GetCurrentThreadId@0
    MSVCRT.lib(gs_support.obj) : error LNK2001: unresolved external symbol __imp__GetCurrentProcessId@0
    MSVCRT.lib(gs_support.obj) : error LNK2001: unresolved external symbol __imp__GetSystemTimeAsFileTime@4
    C:\Users\Bryan\Documents\Visual Studio 2005\Projects\testwin32app\Release\testwin32app.exe : fatal error LNK1120: 33 unresolved externals

    Wednesday, October 31, 2007 11:54 PM
  •  

    Sorry for the two long posts, but for anyone who'd like to help me figure this out, here is the environment portion of the build log:

     

    __COMPAT_LAYER=RunAsAdmin
        _ACP_ATLPROV=C:\Program Files (x86)\Microsoft Visual Studio 8\VC\Bin\ATLProv.dll
        _ACP_INCLUDE=C:\Program Files\Microsoft SDKs\Windows\v6.0\Include;C:\Program Files\Microsoft SDKs\Windows\v6.0\Include\gl;C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include;C:\Program Files (x86)\Microsoft Visual Studio 8\SDK\v2.0\include
        _ACP_LIB=C:\Program Files\Microsoft SDKs\Windows\v6.0\Lib;C:\Program Files (x86)\Microsoft Visual Studio 8\VC\lib;C:\Program Files (x86)\Microsoft Visual Studio 8\SDK\v2.0\lib;C:\Program Files (x86)\Microsoft Visual Studio 8\;C:\Program Files (x86)\Microsoft Visual Studio 8\lib
        _ACP_PATH=C:\Program Files\Microsoft SDKs\Windows\v6.0\bin;C:\Program Files (x86)\Microsoft Visual Studio 8\VC\bin;C:\Program Files (x86)\Microsoft Visual Studio 8\Common7\Tools\bin;C:\Program Files (x86)\Microsoft Visual Studio 8\Common7\tools;C:\Program Files (x86)\Microsoft Visual Studio 8\Common7\ide;C:\Program Files (x86)\HTML Help Workshop;C:\Program Files (x86)\Microsoft Visual Studio 8\SDK\v2.0\bin;C:\Windows\Microsoft.NET\Framework\v2.0.50727;C:\Program Files (x86)\Microsoft Visual Studio 8\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static
        ALLUSERSPROFILE=C:\ProgramData
        APPDATA=C:\Users\**redacted**\AppData\Roaming
        CommonProgramFiles(x86)=C:\Program Files (x86)\Common Files
        CommonProgramFiles=C:\Program Files (x86)\Common Files
        CommonProgramW6432=C:\Program Files\Common Files
        COMPUTERNAME=**redacted**
        ComSpec=C:\Windows\system32\cmd.exe
        FP_NO_HOST_CHECK=NO
        HOMEDRIVE=C:
        HOMEPATH=\Users\**redacted**
        INCLUDE=C:\Program Files\Microsoft SDKs\Windows\v6.0\Include;C:\Program Files\Microsoft SDKs\Windows\v6.0\Include\gl;C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include;C:\Program Files (x86)\Microsoft Visual Studio 8\SDK\v2.0\include
        LIB=C:\Program Files\Microsoft SDKs\Windows\v6.0\Lib\x64;C:\Program Files (x86)\Microsoft Visual Studio 8\VC\lib;C:\Program Files (x86)\Microsoft Visual Studio 8\SDK\v2.0\lib;C:\Program Files (x86)\Microsoft Visual Studio 8\;C:\Program Files (x86)\Microsoft Visual Studio 8\lib
        LIBPATH=C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\v3.0;C:\Windows\Microsoft.NET\Framework\v2.0.50727;C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework;C:\Program Files (x86)\Reference Assemblies\Microsoft\mmc;C:\Program Files (x86)\Reference Assemblies\Microsoft\Tablet PC;C:\Program Files (x86)\Reference Assemblies\Microsoft\UDDI;C:\Program Files (x86)\Reference Assemblies\Microsoft\WindowsPowerShell
        LOCALAPPDATA=C:\Users\**redacted**\AppData\Local
        LOGONSERVER=\\**redacted**
        NUMBER_OF_PROCESSORS=2
        OS=Windows_NT
        PATH=C:\Program Files\Microsoft SDKs\Windows\v6.0\bin;C:\Program Files (x86)\Microsoft Visual Studio 8\VC\bin;C:\Program Files (x86)\Microsoft Visual Studio 8\Common7\Tools\bin;C:\Program Files (x86)\Microsoft Visual Studio 8\Common7\tools;C:\Program Files (x86)\Microsoft Visual Studio 8\Common7\ide;C:\Program Files (x86)\HTML Help Workshop;C:\Program Files (x86)\Microsoft Visual Studio 8\SDK\v2.0\bin;C:\Windows\Microsoft.NET\Framework\v2.0.50727;C:\Program Files (x86)\Microsoft Visual Studio 8\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static
        PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
        PROCESSOR_ARCHITECTURE=x86
        PROCESSOR_ARCHITEW6432=AMD64
        PROCESSOR_IDENTIFIER=EM64T Family 6 Model 15 Stepping 6, GenuineIntel
        PROCESSOR_LEVEL=6
        PROCESSOR_REVISION=0f06
        ProgramData=C:\ProgramData
        ProgramFiles(x86)=C:\Program Files (x86)
        ProgramFiles=C:\Program Files (x86)
        ProgramW6432=C:\Program Files
        PUBLIC=C:\Users\Public
        Rav=C:\ProgramData\Rising\Rav
        SystemDrive=C:
        SystemRoot=C:\Windows
        TEMP=C:\Users\**redacted**\AppData\Local\Temp
        TMP=C:\Users\**redacted**\AppData\Local\Temp
        VS80COMNTOOLS=C:\Program Files (x86)\Microsoft Visual Studio 8\Common7\Tools\
        WecVersionForRosebud.166C=2
        windir=C:\Windows

    Thursday, November 01, 2007 2:36 AM
  • I'm getting a very similar error, only on the command prompt.

    "cannot open file 'user.lib'"

    I have the SDK.
    It is in my C++ Directories in the include, lib, and execuatable folders.

    My solution is to directly edit the vcvars32.bat file and add the same paths for the library that I did to the C++ settings.

    It works, but is it right?
    Wednesday, November 07, 2007 12:41 PM