getting this error on flutter run
for a linux desktop application
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
output of 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!
output of clang --version
Ubuntu clang version 14.0.0-1ubuntu1
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
I noticed that /usr/lib/libstdc .so
was missing, so manually created a symlink
sudo ln -s /usr/lib/x86_64-linux-gnu/libstdc .so.6 /usr/lib/libstdc .so
.
Then I ended up in this error on 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
CodePudding user response:
Turns out, upgrading to clang-14 caused the problem. This is how I fixed it:
- downgrade to clang-13
- create a symlink, if
/usr/lib/libstdc .so
doesnt exists.sudo ln -s /usr/lib/x86_64-linux-gnu/libstdc .so.6 /usr/lib/libstdc .so
- if you are getting
fatal error: 'type_traits' file not found
onflutter run
, export clang include pathexport CPLUS_INCLUDE_PATH="${CPLUS_INCLUDE_PATH: ${CPLUS_INCLUDE_PATH}:}/usr/lib/llvm-13/include/c /v1/"