Bruno.
Bruno.

Reputation: 37

Flutter Linux run and build are not working

I am trying to make a Linux app with flutter, but it doesn't seem to be working.

This is the error that comes up when I run flutter run -d linux or flutter build linux:

Launching lib/main.dart on Linux in debug mode...
/snap/flutter/current/usr/include/sched.h:122:16: error: unknown type name 'cpu_set_t'
/snap/flutter/current/usr/include/sched.h:126:10: error: unknown type name 'cpu_set_t'
/snap/flutter/current/usr/include/pthread.h:374:12: error: unknown type name 'cpu_set_t'
/snap/flutter/current/usr/include/pthread.h:381:6: error: unknown type name 'cpu_set_t'
/snap/flutter/current/usr/include/pthread.h:451:14: error: unknown type name 'cpu_set_t'
/snap/flutter/current/usr/include/pthread.h:456:8: error: unknown type name 'cpu_set_t'
/snap/flutter/current/usr/include/gtk-3.0/gdk/gdkvisual.h:25:2: error: unterminated conditional directive
/snap/flutter/current/usr/include/gtk-3.0/gtk/gtkbutton.h:25:2: error: unterminated conditional directive
/snap/flutter/current/usr/include/gtk-3.0/gtk/gtkcelllayout.h:90:443: error: unknown type name 'll_layout'
/snap/flutter/current/usr/include/gtk-3.0/gtk/gtkcelllayout.h:91:55: error: redefinition of parameter 'cell'
/snap/flutter/current/usr/include/gtk-3.0/gtk/gtkbutton.h:25:2: error: unterminated conditional directive
/snap/flutter/current/usr/include/gtk-3.0/gtk/gtktogglebutton.h:59:18: error: field has incomplete type 'GtkButtonClass' (aka '_GtkButtonClass')
/snap/flutter/current/usr/include/gtk-3.0/gtk/gtkbutton.h:25:2: error: unterminated conditional directive
/snap/flutter/current/usr/include/gtk-3.0/gtk/gtkcolorbutton.h:62:18: error: field has incomplete type 'GtkButtonClass' (aka '_GtkButtonClass')
/snap/flutter/current/usr/include/gtk-3.0/gtk/gtkbutton.h:25:2: error: unterminated conditional directive
/snap/flutter/current/usr/include/gtk-3.0/gtk/gtklinkbutton.h:70:18: error: field has incomplete type 'GtkButtonClass' (aka '_GtkButtonClass')
/snap/flutter/current/usr/include/gtk-3.0/gtk/gtkbutton.h:25:2: error: unterminated conditional directive
/snap/flutter/current/usr/include/gtk-3.0/gtk/gtklockbutton.h:51:18: error: field has incomplete type 'GtkButtonClass' (aka '_GtkButtonClass')
/snap/flutter/current/usr/include/gtk-3.0/gtk/gtkbutton.h:25:2: error: unterminated conditional directive
fatal error: too many errors emitted, stopping now [-ferror-limit=]
/snap/flutter/current/usr/include/sched.h:122:16: error: unknown type name 'cpu_set_t'
/snap/flutter/current/usr/include/sched.h:126:10: error: unknown type name 'cpu_set_t'
/snap/flutter/current/usr/include/pthread.h:374:12: error: unknown type name 'cpu_set_t'
/snap/flutter/current/usr/include/pthread.h:381:6: error: unknown type name 'cpu_set_t'
/snap/flutter/current/usr/include/pthread.h:451:14: error: unknown type name 'cpu_set_t'
/snap/flutter/current/usr/include/pthread.h:456:8: error: unknown type name 'cpu_set_t'
/snap/flutter/current/usr/include/gtk-3.0/gdk/gdkvisual.h:25:2: error: unterminated conditional directive
/snap/flutter/current/usr/include/gtk-3.0/gtk/gtkbutton.h:25:2: error: unterminated conditional directive
/snap/flutter/current/usr/include/gtk-3.0/gtk/gtkcelllayout.h:90:443: error: unknown type name 'll_layout'
/snap/flutter/current/usr/include/gtk-3.0/gtk/gtkcelllayout.h:91:55: error: redefinition of parameter 'cell'
/snap/flutter/current/usr/include/gtk-3.0/gtk/gtkbutton.h:25:2: error: unterminated conditional directive
/snap/flutter/current/usr/include/gtk-3.0/gtk/gtktogglebutton.h:59:18: error: field has incomplete type 'GtkButtonClass' (aka '_GtkButtonClass')
/snap/flutter/current/usr/include/gtk-3.0/gtk/gtkbutton.h:25:2: error: unterminated conditional directive
/snap/flutter/current/usr/include/gtk-3.0/gtk/gtkcolorbutton.h:62:18: error: field has incomplete type 'GtkButtonClass' (aka '_GtkButtonClass')
/snap/flutter/current/usr/include/gtk-3.0/gtk/gtkbutton.h:25:2: error: unterminated conditional directive
/snap/flutter/current/usr/include/gtk-3.0/gtk/gtklinkbutton.h:70:18: error: field has incomplete type 'GtkButtonClass' (aka '_GtkButtonClass')
/snap/flutter/current/usr/include/gtk-3.0/gtk/gtkbutton.h:25:2: error: unterminated conditional directive
/snap/flutter/current/usr/include/gtk-3.0/gtk/gtklockbutton.h:51:18: error: field has incomplete type 'GtkButtonClass' (aka '_GtkButtonClass')
/snap/flutter/current/usr/include/gtk-3.0/gtk/gtkbutton.h:25:2: error: unterminated conditional directive
fatal error: too many errors emitted, stopping now [-ferror-limit=]
/snap/flutter/current/usr/include/sched.h:122:16: error: unknown type name 'cpu_set_t'
/snap/flutter/current/usr/include/sched.h:126:10: error: unknown type name 'cpu_set_t'
/snap/flutter/current/usr/include/pthread.h:374:12: error: unknown type name 'cpu_set_t'
/snap/flutter/current/usr/include/pthread.h:381:6: error: unknown type name 'cpu_set_t'
/snap/flutter/current/usr/include/pthread.h:451:14: error: unknown type name 'cpu_set_t'
/snap/flutter/current/usr/include/pthread.h:456:8: error: unknown type name 'cpu_set_t'
/snap/flutter/current/usr/include/gtk-3.0/gdk/gdkvisual.h:25:2: error: unterminated conditional directive
/snap/flutter/current/usr/include/gtk-3.0/gtk/gtkbutton.h:25:2: error: unterminated conditional directive
/snap/flutter/current/usr/include/gtk-3.0/gtk/gtkcelllayout.h:90:443: error: unknown type name 'll_layout'
/snap/flutter/current/usr/include/gtk-3.0/gtk/gtkcelllayout.h:91:55: error: redefinition of parameter 'cell'
/snap/flutter/current/usr/include/gtk-3.0/gtk/gtkbutton.h:25:2: error: unterminated conditional directive
/snap/flutter/current/usr/include/gtk-3.0/gtk/gtktogglebutton.h:59:18: error: field has incomplete type 'GtkButtonClass' (aka '_GtkButtonClass')
/snap/flutter/current/usr/include/gtk-3.0/gtk/gtkbutton.h:25:2: error: unterminated conditional directive
/snap/flutter/current/usr/include/gtk-3.0/gtk/gtkcolorbutton.h:62:18: error: field has incomplete type 'GtkButtonClass' (aka '_GtkButtonClass')
/snap/flutter/current/usr/include/gtk-3.0/gtk/gtkbutton.h:25:2: error: unterminated conditional directive
/snap/flutter/current/usr/include/gtk-3.0/gtk/gtklinkbutton.h:70:18: error: field has incomplete type 'GtkButtonClass' (aka '_GtkButtonClass')
/snap/flutter/current/usr/include/gtk-3.0/gtk/gtkbutton.h:25:2: error: unterminated conditional directive
/snap/flutter/current/usr/include/gtk-3.0/gtk/gtklockbutton.h:51:18: error: field has incomplete type 'GtkButtonClass' (aka '_GtkButtonClass')
/snap/flutter/current/usr/include/gtk-3.0/gtk/gtkbutton.h:25:2: error: unterminated conditional directive
fatal error: too many errors emitted, stopping now [-ferror-limit=]
Building Linux application...                                           
Exception: Build process failed

This is flutter doctor -v:

[✓] Flutter (Channel master, 3.6.0-1.0.pre.53, on Pop!_OS 22.04 LTS 6.0.6-76060006-generic, locale en_US.UTF-8)
    • Flutter version 3.6.0-1.0.pre.53 on channel master at /home/bruno/snap/flutter/common/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 61e927d22f (2 hours ago), 2022-11-12 04:39:32 -0500
    • Engine revision e63c9443bc
    • Dart version 2.19.0 (build 2.19.0-392.0.dev)
    • DevTools version 2.19.0

Checking Android licenses is taking an unexpectedly long time...[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
    • Android SDK at /home/bruno/Android/Sdk
    • Platform android-33, build-tools 33.0.0
    • Java binary at: /snap/android-studio/124/android-studio/jre/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)
    • All Android licenses accepted.

[✓] Chrome - develop for the web
    • Chrome at google-chrome

[✓] Linux toolchain - develop for Linux desktop
    • clang version 10.0.0-4ubuntu1
    • cmake version 3.16.3
    • ninja version 1.10.0
    • pkg-config version 0.29.1

[✓] Android Studio (version 2021.3)
    • Android Studio at /snap/android-studio/124/android-studio
    • Flutter plugin version 71.0.3
    • Dart plugin version 213.7433
    • Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)

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

[✓] Connected device (2 available)
    • Linux (desktop) • linux  • linux-x64      • Pop!_OS 22.04 LTS 6.0.6-76060006-generic
    • Chrome (web)    • chrome • web-javascript • Google Chrome 107.0.5304.110

[✓] HTTP Host Availability
    • All required HTTP hosts are available

• No issues found!

I tried making a fresh new project with flutter create projectName but the same problem was still there.

I tried updating flutter with flutter channel master and then flutter upgrade but that didn't help either.

I am pretty new to flutter and don't really know much.

Any help would be appreciated!

Upvotes: 3

Views: 1887

Answers (1)

jraufeisen
jraufeisen

Reputation: 3897

There are two things you could try:

  • Investigate if you are using any plugins/packages that are not compatible with Linux.
  • As a follow up: Try to create a new flutter app form scratch and see if the error occurs even without any changes.
  • Upgrade your flutter version via flutter upgrade and remove all build caches via rm -r build.

A related issue on Github also suggests to switch to the edge channel instead of the master channel:

  • snap refresh flutter --edge
  • flutter upgrade
  • rm -r build

Upvotes: 2

Related Questions