flutter run on Linux fails at CMake with cannot find -lstdc++
/usr/bin/ld: cannot find -lstdc++: No such file or directoryShort answer
The Linux desktop build links with clang, and clang cannot find the C++ standard library development files. Install the packages listed in the Flutter Linux setup guide, including libstdc++-dev for your GCC version, then run flutter doctor -v and build again.
Fix it fast
1Find out which cause you have
Ask flutter doctor about the Linux toolchain, and check which libstdc++ development packages are installed.
flutter doctor -v dpkg -l | grep -E 'libstdc\+\+.*-dev'2Match what you see, then jump to its fix
What does the error look like?
/usr/bin/ld: cannot find -lstdc++: No such file or directoryflutter run stops at the CMake step with a C++ compiler test failing at link time
Cause 1 of 2
The libstdc++ development package is missing
1Check
Flutter's Linux setup guide lists libstdc++-12-dev among the packages for apt based systems and says to adjust the package name when your distribution uses a different libstdc++ version. The runtime library alone does not give the linker the -lstdc++ it needs.
apt list --installed 2>/dev/null | grep libstdc++2Fix
Install the toolchain packages from the guide. Use the -dev package that matches the GCC version of your distribution if 12 is not available.
sudo apt-get update -y
sudo apt-get install -y clang cmake ninja-build pkg-config libgtk-3-dev libstdc++-12-dev3Verify
The Linux toolchain section of flutter doctor has no errors, and a build gets past CMake.
flutter doctor -v
flutter run -d linuxConfirmed by docs.flutter.dev
Cause 2 of 2
The rest of the Linux toolchain is incomplete
1Check
The setup guide expects clang, cmake, ninja-build, pkg-config and libgtk-3-dev besides the C++ library, and checks the result with flutter doctor -v and flutter devices. A Flutter maintainer also noted that doctor does not detect every incomplete toolchain, so a clean report is not proof.
flutter devices
clang --version
cmake --version2Fix
Install anything missing from the guide's package list, then run the checks again.
sudo apt-get install -y clang cmake ninja-build pkg-config libgtk-3-dev3Verify
A linux device is listed.
flutter devicesConfirmed by github.com
How do I stop it coming back?
- Install the full package list from the Flutter Linux guide on every new machine or CI image.
- Rerun flutter doctor -v after every distribution upgrade.
- Keep a flutter clean step in CI after changing compilers.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
- TaxiDexMy own multi-tenant taxi dispatch SaaS: API, dispatcher portal, driver and passenger apps, and the servers underneath.
- Dispatch ProA real-time logistics platform: Flutter apps, Spring Boot services and a Kafka event pipeline on AWS.
- Qist BazaarA buy-now-pay-later marketplace built from a blank repo, now past 100K downloads on Google Play.
Related fixes
Mobile apps
A phone is plugged in over USB but Android Studio and adb do not list it
adb devices prints List of devices attached with nothing below it
adb lists a phone only when four things hold: USB debugging is on, you accepted the computer's RSA key on the phone, the computer has a driver or udev rule for the device, and the cable carries data to a running adb server.
6 causes, each with a fixMobile apps
Terminal says pub: command not found after installing Dart
dart: command not found
The standalone pub program no longer exists in current Dart.
2 causes, each with a fixMobile apps
Flutter web cannot find Chrome and asks for CHROME_EXECUTABLE
Cannot find Chrome executable at
Flutter looks for Chrome in one fixed place per operating system, unless CHROME_EXECUTABLE is set.
4 causes, each with a fixMobile apps
flutter doctor says the Android cmdline-tools component is missing
Android license status unknown.
Flutter checks for a cmdline-tools folder inside the Android SDK it found, and stops the Android checks when that folder is absent.
6 causes, each with a fixMobile apps
The terminal cannot find the flutter or dart command
zsh: command not found: flutter
The flutter and dart programs both live in the bin folder of the Flutter SDK, so one PATH entry gives you both.
3 causes, each with a fixMobile apps
flutter doctor warns that dart on your path is not in the Flutter SDK
Consider adding C:\flutter\bin to the front of your path.
flutter doctor found a dart program on your PATH that lives outside the Flutter SDK folder, usually a separate Dart SDK installed earlier in the list.
3 causes, each with a fix