Search code examples
flutterdartflutter-windows

Flutter error: No CMAKE_CXX_COMPILER could be found


I am new to Flutter. When I want to run my Flutter application on Windows, I get this error:

Launching lib\main.dart on Windows in debug mode...
CMake Error at CMakeLists.txt:2 (project):
  No CMAKE_CXX_COMPILER could be found.



Building Windows application...
Exception: Unable to generate build files

Here is the output of flutter doctor -v:

[√] Flutter (Channel stable, 2.10.4, on Microsoft Windows [Version 10.0.19043.1586], locale en-US)
    • Flutter version 2.10.4 at E:\Flutter\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision c860cba910 (4 days ago), 2022-03-25 00:23:12 -0500
    • Engine revision 57d3bac3dd
    • Dart version 2.16.2
    • DevTools version 2.9.2

[√] Android toolchain - develop for Android devices (Android SDK version 31.0.0-rc4)
    • Android SDK at C:\Users\moham\AppData\Local\Android\sdk
    • Platform android-31, build-tools 31.0.0-rc4
    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6842174)
    • All Android licenses accepted.

[√] Chrome - develop for the web
    • Chrome at C:\Program Files (x86)\Google\Chrome\Application\chrome.exe

[√] Visual Studio - develop for Windows (Visual Studio Community 2022 17.1.2)
    • Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community
    • Visual Studio Community 2022 version 17.1.32319.34
    • Windows 10 SDK version 10.0.19041.0

[√] Android Studio (version 4.2)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6842174)

[√] Connected device (3 available)
    • Windows (desktop) • windows • windows-x64    • Microsoft Windows [Version 10.0.19043.1586]
    • Chrome (web)      • chrome  • web-javascript • Google Chrome 99.0.4844.84
    • Edge (web)        • edge    • web-javascript • Microsoft Edge 98.0.1108.62

[√] HTTP Host Availability
    • All required HTTP hosts are available

• No issues found!

Everything is OK. Where is the problem is?

I read all the previous answers, but nothing worked for me.


Solution

  • I solved the problem, but I don't know what the solution is exactly.

    I think the solution was to uninstall the whole "Desktop Development With C++" from Visual Studio and reinstall it.

    Then in the directory of my Flutter project:

    flutter clean and flutter create .