Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Flutter and app store releases

flutter run on Linux fails at CMake with cannot find -lstdc++

Error/usr/bin/ld: cannot find -lstdc++: No such file or directory

Short 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.

  • Applies to Flutter 3.3x stable, Ubuntu 24.04, clang 18
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 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'
  2. 2Match what you see, then jump to its fix

    1. 1dpkg shows no libstdc++-NN-dev line, or the line is for another version than your compiler suite.The libstdc++ development package is missingFix
    2. 2flutter doctor shows a problem under Linux toolchain, or does not list a linux device.The rest of the Linux toolchain is incompleteFix

What does the error look like?

  • /usr/bin/ld: cannot find -lstdc++: No such file or directory
  • flutter 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-dev

3Verify

The Linux toolchain section of flutter doctor has no errors, and a build gets past CMake.

flutter doctor -v
flutter run -d linux

Confirmed by docs.flutter.dev

Did this fix it?

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 --version

2Fix

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-dev

3Verify

A linux device is listed.

flutter devices

Confirmed by github.com

Did this fix it?

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:

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 fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.