Flutter linux 在 Ubuntu 22.04 LTS CMake 错误上构建

标签 flutter ubuntu flutter-desktop flutter-linux

我有 flutter 项目,可以在 Ubuntu 20.04 上成功构建。现在我想在 Ubuntu 22.04 上构建它,但出现 CMake 错误。

CMake Error at /snap/flutter/111/usr/share/cmake-3.10/Modules/CMakeTestCXXCompiler.cmake:45 (message):
  The C++ compiler

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

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: /home/arzak/StudioProjects/testlinux/build/linux/x64/debug/CMakeFiles/CMakeTmp

    Run Build Command:"/snap/flutter/current/usr/bin/ninja" "cmTC_38e6c"
    [1/2] Building CXX object CMakeFiles/cmTC_38e6c.dir/testCXXCompiler.cxx.o
    [2/2] Linking CXX executable cmTC_38e6c
    FAILED: cmTC_38e6c 
    : && /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/ CMakeFiles/cmTC_38e6c.dir/testCXXCompiler.cxx.o  -o cmTC_38e6c   && :
    /snap/flutter/current/usr/bin/ld: warning: /usr/lib/gcc/x86_64-linux-gnu/11/../../../x86_64-linux-gnu/crt1.o: unsupported GNU_PROPERTY_TYPE (5) type: 0xc0008002
    /usr/lib/gcc/x86_64-linux-gnu/11/../../../x86_64-linux-gnu/libgcc_s.so.1: undefined reference to `_dl_find_object@GLIBC_2.35'
    //lib/x86_64-linux-gnu/libgpg-error.so.0: undefined reference to `__libc_single_threaded@GLIBC_2.32'
    //lib/x86_64-linux-gnu/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 will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:3 (project)

我已经使用 sudo apt-get install clang cmake ninja-build pkg-config libgtk-3-dev 安装了 clang 和其他软件

这是 flutter doctor 结果

[✓] Flutter (Channel stable, 3.0.0, on Ubuntu 22.04 LTS 5.15.0-27-generic,
    locale en_US.UTF-8)
[✓] Android toolchain - develop for Android devices (Android SDK version
    32.1.0-rc1)
[✗] Chrome - develop for the web (Cannot find Chrome executable at
    google-chrome)
    ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.
[✓] Linux toolchain - develop for Linux desktop
[✓] Android Studio (version 2021.2)
[✓] Connected device (1 available)
[✓] HTTP Host Availability

! Doctor found issues in 1 category.

最佳答案

感谢Pkrarakal ,我关注他suggestion错误消失了。 试试这个步骤:

  • 移动到边缘 channel ,snap refresh flutter --edge
  • 运行 flutter upgrade
  • 删除构建目录 rm -r build/
  • 再次运行应用程序 flutter flutter run -d linux

关于Flutter linux 在 Ubuntu 22.04 LTS CMake 错误上构建,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72223978/

相关文章:

linux - 异常 : No Linux desktop project configured error on flutter project

flutter - Flutter 桌面版中的 YouTube 播放器 (Windows)

Flutter:堆栈中的 ontap

Flutter:带相机插件的 Live ml kit 文本识别

git - 如何从 Github 安装 MegaFuse?在 Ubuntu 上

python - fatal error : cuda_runtime_api. h:尝试在 docker 中使用 cuda 时没有这样的文件或目录

android - 缺少插件异常(在 channel plugins.flutter.io/firebase_core 上找不到方法 firebase#initializecore 的实现)

webview - Flutter:Web View 应用程序仅在应用程序中运行特定网站,其他网站在手机本地浏览器中打开

flutter - 在Flutter中,如何创建一个带有毛玻璃效果的SliverAppBar?

ruby-on-rails - ruby on rails 无法在本地连接到 postgresql