CMake configuring fails. “cl.exe is not able to compile a simple test program”

前端 未结 5 1479
南笙
南笙 2020-12-08 03:18

I am trying to build a solution for MSVC++2010 using CMake. Since I installed Visual Studio 2012 that does not work anymore. CMake comes with the following error message: \"

相关标签:
5条回答
  • 2020-12-08 03:22

    I had the same problem. The above solution didn't work out for me. My problem was solved after looking into this post.

    First, check if you have .NET 4.5 on your system. If you do, that is very likely causing the problem. Try either upgrading to VS2010 SP1 or downgrade .NET to 4.0

    CAUSES:

    This error appears because you have installed Visual C++ 2012 after you have actually installed Visual C++ 2010 in your system; another cause is because .net Framework 4.5 replace .net Framework 4.0; .net Framework corrupted files;

    HOW TO SOLVE

    Uninstall .NET Framework 4.5 from your system; then download .NET Framework 4.0 and install it; this should fix your problem;

    0 讨论(0)
  • 2020-12-08 03:33

    I had the same problem on Win7.
    What worked for me is what @Andre suggested in the comment:

    1. Right-Click->Properties on cl.exe in your VS install directory (the exact path appears in the CMake error);
    2. Choose the Compatibility Tab;
    3. Check "Run this program as administrator" in the "Privilege Level" box.
    0 讨论(0)
  • 2020-12-08 03:37

    I encountered a similar problem,

    In my case, running Visual Studio 2017 as administrator and applying @Adi Shavit's answer worked.

    0 讨论(0)
  • 2020-12-08 03:39

    I have met this problem, and I fixed by this way. You should run cmake in a console, command like

    >vcvars32  (to set some system vars, C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\vcvar32.bat)
    
    >cmake .. -G"NMake Makefiles" (.. is your code folder) 
    
    >nmake  (It will work well!)
    

    You should do this jod in one console, don't open another.

    0 讨论(0)
  • 2020-12-08 03:44

    I encounter the excatly same problem. I solved by add a command before cmake

    call "C:/Program Files (x86)/VC/vcvarsall.bat" amd64

    The path of vcvarsall.bat and the architecture maybe different on your computer.

    According to Usage of vcvarsall.bat, this command is to set up proper environment variable for command-line compilation.

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