Repository: flutter
Issue: Invalid toolchain leads to CMake error when compiling, flutter doctor does not detect this
Labels: tool,a: first hour,platform-linux,a: desktop,a: build,P2,team-linux,triaged-linux

### Steps to reproduce

Three simple steps to reproduce my problems.

flutter create [project name]
flutter run
2 (for linux)


### Expected results

This should open a gtk3 app with the basics running.

### Actual results

I get this output instead: 

```console
Connected devices:
Linux (desktop) • linux  • linux-x64      • Pop!_OS
22.04 LTS 6.6.10-76060610-generic
Chrome (web)    • chrome • web-javascript • Google
Chrome 122.0.6261.94
[1]: Linux (linux)
[2]: Chrome (chrome)
Please choose one (or "q" to quit): 1

Launching lib/main.dart on Linux in debug mode...
Building Linux application...
Building Linux application...                          CMake Error at /usr/share/cmake-3.22/Modules/CMakeTestCXXCompiler.cmake:62 (message):
Building Linux application...                            The C++ compiler
Building Linux application...                              "/usr/bin/clang++"
Building Linux application...                            is not able to compile a simple test program.
Building Linux application...
Building Linux application...                            It fails with the following output:
Building Linux application...                              Change Dir: /home/[redacted]/Programs/[redacted]/app/build/linux/x64/debug/CMakeFiles/CMakeTmp
Building Linux application...
Building Linux application...                              Run Build Command(s):/usr/bin/ninja cmTC_09ee2 && [1/2] Building CXX object CMakeFiles/cmTC_09ee2.dir/testCXXCompiler.cxx.o
Building Linux application...                              [2/2] Linking CXX executable cmTC_09ee2
Building Linux application...                              FAILED: cmTC_09ee2
Building Linux application...                              : && /usr/bin/clang++   CMakeFiles/cmTC_09ee2.dir/testCXXCompiler.cxx.o -o cmTC_09ee2   && :
Building Linux application...                              /usr/bin/ld: cannot find -lstdc++: No such file or directory
Building Linux application...                              clang: error: linker command failed with exit code 1 (use -v to see invocation)
Building Linux application...                              ninja: build stopped: subcommand failed.

Building Linux application...                            CMake will not be able to correctly generate this project.
Building Linux application...                          Call Stack (most recent call first):
Building Linux application...                            CMakeLists.txt:3 (project)
Error: Unable to generate build files
```

I changed nothing in my dart file from the initial project created by flutter create. 

### Code sample

<details open><summary>Code sample</summary>

```dart
[Paste your code here]
```

</details>


### Screenshots or Video

<details open>
<summary>Screenshots / Video demonstration</summary>

[Upload media here]

</details>


### Logs

<details open><summary>Logs</summary>

```console
[Paste your logs here]
```

</details>


### Flutter Doctor output

<details open><summary>Doctor output</summary>

```console
<lutte                                                                                                        utter doctor
Doctor summary (to see all details, run flutter doctor
-v):
[✓] Flutter (Channel stable, 3.19.2, on Pop!_OS 22.04
    LTS 6.6.10-76060610-generic, locale en_CA.UTF-8)
[✗] Android toolchain - develop for Android devices
    ✗ Unable to locate Android SDK.
      Install Android Studio from:
      https://developer.android.com/studio/index.html
      On first launch it will assist you in installing
      the Android SDK components.
      (or visit
      https://flutter.dev/docs/get-started/install/linu
      x#android-setup for detailed instructions).
      If the Android SDK has been installed to a custom
      location, please use
      `flutter config --android-sdk` to update to that
      location.

[✓] Chrome - develop for the web
[✓] Linux toolchain - develop for Linux desktop
[!] Android Studio (not installed)
[✓] VS Code (version 1.87.0)
[✓] Connected device (2 available)
[✓] Network resources

! Doctor found issues in 2 categories.
```

</details>