LINK: fatal error LNK 1104: cannot open file 'LIBCMT.lib'

后端 未结 7 1530
情深已故
情深已故 2021-01-08 00:31

Please help, I have spent all day trying to make my c++ app compile.

My project contains one source file: Foo.cpp. Here is its code:

#include 

        
相关标签:
7条回答
  • 2021-01-08 00:59

    I got this same error when running cl.exe from the Developer Command Prompt for VS2012 command window. Turned out all I had to do was restart the command prompt by right-clicking on it and choosing Run as administrator.

    0 讨论(0)
  • 2021-01-08 01:02

    Right click on ProjectName (within Solution Explorer) -> Properties -> Linker -> General -> Additional Library Directories and set it like this:

    $(SolutionDir)$(Platform)\$(Configuration)\;$(VCToolsInstallDir)\lib\$(PlatformShortName);$(VCToolsInstallDir)atlmfc\lib\$(PlatformShortName)
    
    0 讨论(0)
  • 2021-01-08 01:03

    Running cl.exe directly requires that environment variables are set that point to libraries and tools. To get an idea of what variables need installed and what their values should be, I recommend installing Microsoft Visual C++ Compiler for Python 2.7. It adds command prompts to the start menu which automatically load the needed environment variables.

    After running the prompt, run set to see all of the environment variables.

    Examples:

    LIB=C:\Users\JBeach\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Lib;C:\Users\JBeach\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\WinSDK\Lib;
    LIBPATH=C:\Users\JBeach\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Lib;C:\Users\JBeach\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\WinSDK\Lib;
    PROCESSOR_ARCHITECTURE=x86
    PROCESSOR_ARCHITEW6432=AMD64
    VCINSTALLDIR=C:\Users\JBeach\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\
    WindowsSdkDir=C:\Users\JBeach\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\WinSDK\
    
    0 讨论(0)
  • 2021-01-08 01:08

    This worked for me when I got …

    fatal error LNK1104: cannot open file 'LIBCMT.lib'
    

    Your project name == “Project Name” for this example.

    Go to the 'Solution Explorer' window for your Project.

    RIGHT Click on the Project "Project Name", not the Solution "Project Name".

    This will open a long menu.

    At the bottom is "Properties" Click on it.

    This will open the “Project Name” Property Pages window.

    IF the name of the window (upper left) says...

    “Solution 'Project Name' Property Pages

    Close this window, you right clicked on the Solution, not the Project, you need to right click on the project name.

    On the “Project Name” Property Pages

    Left hand panel expand Configuration Properties

    Then click on General

    Now the right panel should show the 'General' Configuration Properties' for your current Project.

    Look down the list to 'Platform Toolset'

    If the version of VS you are using is not the one listed you needed to change it.

    To change the version of VS just put you mouse pointer at the end of the current VS version name that is displayed and click.

    A box with a down arrow will show at the right hand side of that row, click on it.

    This will open a window with a list of VS versions.

    Pick the version of VS you are NOW using.

    That window should close, and your selection should have replaced the old project VS version that was used to build your project when I was first built.

    Then at bottom of “Project Name” Property Pages click Apply, then OK.

    Now try to build Project.

    I hope this helps, it works for me when working on projects that were built with earlier versions of VS.

    Good luck Mike.

    0 讨论(0)
  • 2021-01-08 01:11

    Just to add my experience here, since it may help someone, and it applies to newer VS editions (2017 in my case).

    I was getting a similar error during compiling when I moved my project to a new machine. I finally figured out that one of the projects in my dependencies had spectre mitigation turned on, and the libs with that support are not included by default:

    0 讨论(0)
  • 2021-01-08 01:12

    Resurrecting this thread in late 2018 since none of the other solutions helped my case :)

    For me this error started appearing out of nowhere after i installed Windows Driver Kit for a completely unrelated project.

    If you don't need "Spectre Mitigation" (you most likely do not) and seeing this error it's highly probable that you just have to set Project Properties (property pages) -> Configuration Properties -> C/C++ -> Code Generation -> Spectre Mitigation to Disabled.

    Magically it was set to Enabled by the installer of Visual Studio tools for WDK in all projects even tho they got nothing to do with WDK nor the Platform toolset was selected for any driver related stuff. Microsoft at its finest.

    0 讨论(0)
提交回复
热议问题