为什么 flutter 运行 不能在 manjaro linux 上运行?

why flutter run not working on manjaro linux?

我是运行扑3.0.0

$ flutter run -d linux or flutter run

正在 Linux 上以调试模式启动 lib/main.dart... /var/lib/snapd/snap/flutter/111/usr/share/cmake-3.10/Modules/CMakeTestCXXCompiler.cmake:45 处的 CMake 错误(消息): C++ 编译器

"/snap/flutter/current/usr/bin/clang++"

无法编译简单的测试程序。

失败并输出以下内容:

Change Dir: /home/xxx/AndroidStudioProjects/myapp/build/linux/x64/debug/CMakeFiles/CMakeTmp

Run Build Command:"/snap/flutter/current/usr/bin/ninja" "cmTC_8627d"
[1/2] Building CXX object CMakeFiles/cmTC_8627d.dir/testCXXCompiler.cxx.o
[2/2] Linking CXX executable cmTC_8627d
FAILED: cmTC_8627d 
: && /snap/flutter/current/usr/bin/clang++    -L/snap/flutter/current/usr/lib/gcc/x86_64-linux-gnu/8 -L/snap/flutter/current/usr/lib/x86_64-linux-gnu -lblkid -lgcrypt -llzma -lpthread -ldl -L/snap/flutter/current/usr/lib/ -L/snap/flutter/current/usr/lib/gcc/x86_64-linux-gnu/8 -L/snap/flutter/current/usr/lib/x86_64-linux-gnu -lblkid -lgcrypt -llzma -lpthread -ldl -L/snap/flutter/current/usr/lib/ CMakeFiles/cmTC_8627d.dir/testCXXCompiler.cxx.o  -o cmTC_8627d   && :
/snap/flutter/current/usr/bin/ld: warning: /usr/lib64/gcc/x86_64-pc-linux-gnu/11.2.0/../../../../lib64/crt1.o: unsupported GNU_PROPERTY_TYPE (5) type: 0xc0008002
/snap/flutter/current/usr/bin/ld: warning: /usr/lib64/gcc/x86_64-pc-linux-gnu/11.2.0/../../../../lib64/crt1.o: unsupported GNU_PROPERTY_TYPE (5) type: 0xc0010001
/snap/flutter/current/usr/bin/ld: warning: /usr/lib64/gcc/x86_64-pc-linux-gnu/11.2.0/../../../../lib64/crt1.o: unsupported GNU_PROPERTY_TYPE (5) type: 0xc0010002
/snap/flutter/current/usr/bin/ld: warning: /usr/lib64/gcc/x86_64-pc-linux-gnu/11.2.0/../../../../lib64/crti.o: unsupported GNU_PROPERTY_TYPE (5) type: 0xc0010002
/snap/flutter/current/usr/bin/ld: warning: /usr/lib64/gcc/x86_64-pc-linux-gnu/11.2.0/../../../../lib64/crti.o: unsupported GNU_PROPERTY_TYPE (5) type: 0xc0010001
/snap/flutter/current/usr/bin/ld: warning: /usr/lib64/gcc/x86_64-pc-linux-gnu/11.2.0/crtbegin.o: unsupported GNU_PROPERTY_TYPE (5) type: 0xc0010002
/snap/flutter/current/usr/bin/ld: warning: /usr/lib64/gcc/x86_64-pc-linux-gnu/11.2.0/crtbegin.o: unsupported GNU_PROPERTY_TYPE (5) type: 0xc0010001
/snap/flutter/current/usr/bin/ld: warning: /usr/lib64/gcc/x86_64-pc-linux-gnu/11.2.0/../../../../lib64/libgcc_s.so.1: unsupported GNU_PROPERTY_TYPE (5) type: 0xc0010001
/snap/flutter/current/usr/bin/ld: warning: /usr/lib64/gcc/x86_64-pc-linux-gnu/11.2.0/../../../../lib64/libgcc_s.so.1: unsupported GNU_PROPERTY_TYPE (5) type: 0xc0010002
/snap/flutter/current/usr/bin/ld: warning: /usr/lib64/gcc/x86_64-pc-linux-gnu/11.2.0/../../../../lib64/libgcc_s.so.1: unsupported GNU_PROPERTY_TYPE (5) type: 0xc0010001
/snap/flutter/current/usr/bin/ld: warning: /usr/lib64/gcc/x86_64-pc-linux-gnu/11.2.0/../../../../lib64/libgcc_s.so.1: unsupported GNU_PROPERTY_TYPE (5) type: 0xc0010002
/snap/flutter/current/usr/bin/ld: warning: /usr/lib64/gcc/x86_64-pc-linux-gnu/11.2.0/crtend.o: unsupported GNU_PROPERTY_TYPE (5) type: 0xc0010002
/snap/flutter/current/usr/bin/ld: warning: /usr/lib64/gcc/x86_64-pc-linux-gnu/11.2.0/crtend.o: unsupported GNU_PROPERTY_TYPE (5) type: 0xc0010001
/snap/flutter/current/usr/bin/ld: warning: /usr/lib64/gcc/x86_64-pc-linux-gnu/11.2.0/../../../../lib64/crtn.o: unsupported GNU_PROPERTY_TYPE (5) type: 0xc0010002
/snap/flutter/current/usr/bin/ld: warning: /usr/lib64/gcc/x86_64-pc-linux-gnu/11.2.0/../../../../lib64/crtn.o: unsupported GNU_PROPERTY_TYPE (5) type: 0xc0010001
/snap/flutter/current/usr/bin/ld: warning: //usr/lib32/libgpg-error.so.0: unsupported GNU_PROPERTY_TYPE (5) type: 0xc0010001
/snap/flutter/current/usr/bin/ld: warning: //usr/lib32/libgpg-error.so.0: unsupported GNU_PROPERTY_TYPE (5) type: 0xc0010002
/snap/flutter/current/usr/bin/ld: warning: //lib64/libgpg-error.so.0: unsupported GNU_PROPERTY_TYPE (5) type: 0xc0010001
/snap/flutter/current/usr/bin/ld: warning: //lib64/libgpg-error.so.0: unsupported GNU_PROPERTY_TYPE (5) type: 0xc0010002
//lib64/libgpg-error.so.0: undefined reference to `__libc_single_threaded@GLIBC_2.32'
//lib64/libgpg-error.so.0: undefined reference to `pthread_mutex_trylock@GLIBC_2.34'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.

CMake 将无法正确生成该项目。 调用堆栈(最近的调用在前): CMakeLists.txt:3(项目)

正在构建 Linux 应用程序...
异常:无法生成构建文件

我遇到了同样的问题。

根据关于 this Github issue 的讨论,问题似乎可以归结为 snap 本身附带的库。

我通过切换到 edge 并从头开始重建应用程序,设法在 Manjaro 上 运行 获得了它(和你有同样的问题):

# Switch to the edge channel instead of stable
snap refresh flutter --edge

# Clean out the current build dir.
rm -rf ./build

# Try running again
flutter run -d linux

边缘通道可能不是生产代码的好选择,但如果你只是想深入了解一下 Linux 模式,它应该没问题:)