flutter build linux --> clang: error: linker command failed

967 Views Asked by At

"flutter build linux" output:

 Building with sound null safety      
clang: error: linker command failed with exit code 1 (use -v to see invocation) Building Linux application...                         
Build process failed

"flutter doctor -v" output:

[✓] Flutter (Channel stable, 2.5.3, on Ubuntu 20.04.2 LTS 5.11.0-41-generic, locale C.UTF-8)
    • Flutter version 2.5.3 at /home/MyHome/snap/flutter/common/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 18116933e7 (8 weeks ago), 2021-10-15 10:46:35 -0700
    • Engine revision d3ea636dc5
    • Dart version 2.14.4
    • Pub download mirror https://pub.flutter-io.cn
    • Flutter download mirror https://storage.flutter-io.cn

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
    • Android SDK at /home/MyHome/Documents/Apps/Android/Sdk/
    • Platform android-30, build-tools 30.0.2
    • ANDROID_SDK_ROOT = /home/MyHome/Documents/Apps/Android/Sdk/
    • Java binary at: /home/MyHome/Documents/Apps/Android/android-studio/jre/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)
    • All Android licenses accepted.

[✓] Chrome - develop for the web
    • CHROME_EXECUTABLE = /opt/brave.com/brave/brave-browser

[✓] Linux toolchain - develop for Linux desktop
    • clang version 6.0.0-1ubuntu2 (tags/RELEASE_600/final)
    • cmake version 3.10.2
    • ninja version 1.8.2
    • pkg-config version 0.29.1

[✓] Android Studio (version 2020.3)
    • Android Studio at
      /home/MyHome/Documents/Apps/Android/android-studio-ide-201.6953283-linux/android-studio
    • Flutter plugin version 58.0.2
    • Dart plugin version 203.8292
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)

[✓] Android Studio
    • Android Studio at /home/MyHome/Documents/Apps/Android/android-studio
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart
    • android-studio-dir = /home/MyHome/Documents/Apps/Android/android-studio
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)

[✓] VS Code (version 1.63.0)
    • VS Code at /usr/share/code
    • Flutter extension version 3.29.0

[✓] Connected device (2 available)
    • Linux (desktop) • linux  • linux-x64      • Ubuntu 20.04.2 LTS 5.11.0-41-generic
    • Chrome (web)    • chrome • web-javascript • Brave Browser 96.1.32.115

• No issues found!

<br/>
"uname -a" output:

Linux X200 5.11.0-41-generic #45~20.04.1-Ubuntu SMP Wed Nov 10 10:20:10 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

I removed and reinstalled flutter and clang several times but I still didn't see any changes about the above problem and when I run build with -v I receive this:

"flutter build linux -v" output:

Output on pastebin.com

1

There are 1 best solutions below

2
On

It appears that a third-party referenced library link failed to obtain this problem due to the inconsistency between the execution version and the official Flutter supported version

  1. Update apt

    sudo apt update

  2. Upgrade the C library

    sudo apt full-upgrade

Really can't update the Linux kernel, the final solution