6

I have flutter project and can be build successfully on Ubuntu 20.04. Now I want to build it on Ubuntu 22.04 but I got CMake Error.

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)

I've installed clang and others using sudo apt-get install clang cmake ninja-build pkg-config libgtk-3-dev

this is the flutter doctor results

[✓] 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.
2

1 Answer 1

4

Thanks to Pkrarakal, I follow his suggestion and the error was gone. Try this steps :

  • moving to edge channel, snap refresh flutter --edge
  • running flutter upgrade
  • deleting build directory rm -r build/
  • running the application again flutter flutter run -d linux
Sign up to request clarification or add additional context in comments.

1 Comment

I needed to install Flutter manually as I've added flutter_secure_storage to the project. After removing the Flutter snap I was not able to run the Linux app with error '/snap/flutter/current/usr/bin/ninja--version no such file or directory'. Removing build directory helped me to resolve this issue

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.