我正在尝试使用Flutter制作Linux应用程序,但似乎无法正常工作。
当我运行flutter run -d linux
或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
这是
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!
我尝试使用
flutter create projectName
创建一个全新的项目,但仍然存在相同的问题。我尝试使用
flutter channel master
和flutter upgrade
更新flutter,但也没有帮助。我对flutter还不是很了解。
非常感谢您的帮助!