flutter run
时出现此错误。Running "flutter pub get" in proj... 5.3s
Launching lib/main.dart on Linux in debug mode...
CMake Error at /usr/share/cmake-3.22/Modules/CMakeTestCXXCompiler.cmake:62 (message):
The C++ compiler
"/usr/bin/clang++"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: /media/kingbob/Dvolve/EData/proj/build/linux/x64/debug/CMakeFiles/CMakeTmp
Run Build Command(s):/usr/bin/ninja cmTC_5f1b6 && [1/2] Building CXX object CMakeFiles/cmTC_5f1b6.dir/testCXXCompiler.cxx.o
[2/2] Linking CXX executable cmTC_5f1b6
FAILED: cmTC_5f1b6
: && /usr/bin/clang++ CMakeFiles/cmTC_5f1b6.dir/testCXXCompiler.cxx.o -o cmTC_5f1b6 && :
/usr/bin/ld: cannot find -lstdc++: No such file or directory
clang: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:2 (project)
Building Linux application...
Exception: Unable to generate build files
flutter doctor 的输出结果
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.3.8, on Ubuntu 22.04.1 LTS 5.15.0-53-generic, locale en_IN)
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
[✓] Chrome - develop for the web
[✓] Linux toolchain - develop for Linux desktop
[✓] Android Studio (version 2021.3)
[✓] Connected device (2 available)
[✓] HTTP Host Availability
• No issues found!
clang++ --version 的输出
Ubuntu clang version 14.0.0-1ubuntu1
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
我注意到缺少了 /usr/lib/libstdc++.so
,因此手动创建了符号链接 sudo ln -s /usr/lib/x86_64-linux-gnu/libstdc++.so.6 /usr/lib/libstdc++.so
。
然后在执行 flutter run
时遇到了这个错误。
Launching lib/main.dart on Linux in debug mode...
/usr/include/glib-2.0/glib/glib-typeof.h:39:10: fatal error: 'type_traits' file not found
/usr/include/glib-2.0/glib/glib-typeof.h:39:10: fatal error: 'type_traits' file not found
/usr/include/glib-2.0/glib/glib-typeof.h:39:10: fatal error: 'type_traits' file not found
/usr/include/glib-2.0/glib/glib-typeof.h:39:10: fatal error: 'type_traits' file not found
/usr/include/glib-2.0/glib/glib-typeof.h:39:10: fatal error: 'type_traits' file not found
/usr/include/glib-2.0/glib/glib-typeof.h:39:10: fatal error: 'type_traits' file not found
sudo apt install libstdc++-12-dev
对我有效。 - Mattia Dinosaur