google / flutter-desktop-embedding

Experimental plugins for Flutter for Desktop
Apache License 2.0
7.1k stars 605 forks source link

Library compilation is failing with error: unnecessary parentheses in declaration #119

Closed mrhdias closed 5 years ago

mrhdias commented 5 years ago

Archlinux / gcc version 8.2.0 (GCC)

$ cd flutter-desktop-embedding/linux/library/ $ make

g++ -std=c++14 -Wall -Werror -shared -fPIC -I../.. -I/home/hdias/Downloads/development/flutter-desktop-embedding/linux/library/include -I/usr/include/gtk-3.0 -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/fribidi -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/harfbuzz -I/usr/include/uuid -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/libdrm -I/usr/include/atk-1.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/at-spi-2.0 -I/usr/include/dbus-1.0 -I/usr/lib/dbus-1.0/include -pthread src/json_method_call.cc src/method_result.cc src/json_plugin.cc src/method_codec.cc src/plugin.cc src/internal/text_input_model.cc src/internal/text_input_plugin.cc src/internal/engine_method_result.cc src/internal/plugin_handler.cc src/embedder.cc src/method_call.cc src/json_method_codec.cc -L/home/hdias/Downloads/development/flutter-desktop-embedding/linux/library -lgtk-3 -lgdk-3 -lpangocairo-1.0 -lpango-1.0 -latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0 -lepoxy -lX11 -ljsoncpp -lglfw -lGL -lflutter_engine -Wl,-rpath=/home/hdias/Downloads/development/flutter-desktop-embedding/linux/library -o libflutter_embedder.so In file included from /usr/include/gtk-3.0/gtk/gtk.h:100, from src/embedder.cc:18: /usr/include/gtk-3.0/gtk/gtkfilechooserbutton.h:66:8: error: unnecessary parentheses in declaration of ‘gtk_reserved1’ [-Werror=parentheses] void (*__gtk_reserved1); ^ /usr/include/gtk-3.0/gtk/gtkfilechooserbutton.h:67:8: error: unnecessary parentheses in declaration of ‘gtk_reserved2’ [-Werror=parentheses] void (__gtk_reserved2); ^ /usr/include/gtk-3.0/gtk/gtkfilechooserbutton.h:68:8: error: unnecessary parentheses in declaration of ‘__gtk_reserved3’ [-Werror=parentheses] void (gtk_reserved3); ^ /usr/include/gtk-3.0/gtk/gtkfilechooserbutton.h:69:8: error: unnecessary parentheses in declaration of ‘__gtk_reserved4’ [-Werror=parentheses] void (*gtk_reserved4); ^ In file included from /usr/include/gtk-3.0/gtk/gtk.h:271, from src/embedder.cc:18: /usr/include/gtk-3.0/gtk/deprecated/gtkstatusicon.h:74:8: error: unnecessary parentheses in declaration of ‘gtk_reserved1’ [-Werror=parentheses] void (*__gtk_reserved1); ^ /usr/include/gtk-3.0/gtk/deprecated/gtkstatusicon.h:75:8: error: unnecessary parentheses in declaration of ‘gtk_reserved2’ [-Werror=parentheses] void (__gtk_reserved2); ^ /usr/include/gtk-3.0/gtk/deprecated/gtkstatusicon.h:76:8: error: unnecessary parentheses in declaration of ‘__gtk_reserved3’ [-Werror=parentheses] void (gtk_reserved3); ^ /usr/include/gtk-3.0/gtk/deprecated/gtkstatusicon.h:77:8: error: unnecessary parentheses in declaration of ‘__gtk_reserved4’ [-Werror=parentheses] void (*gtk_reserved4); ^ cc1plus: all warnings being treated as errors make: *** [Makefile:41: libflutter_embedder.so] Error 1

awdavies commented 5 years ago

The line is failing on the include statement:

#include <gtk/gtk.h>

Can you give me the output of the two commands in isolation:

pkg-config --cflags gtk+-3.0

and

pkg-config --libs gtk+-3.0

Also, are you able to build a simple example app using GTK?

awdavies commented 5 years ago

According to this thread (was doing some cursory searching), the issue is from a recent addition to GCC around v8.0 I believe? Mine is only on v7.3 which would explain why I can't reproduce.

Perhaps an addition to the README to have GTK updated to 3.22 if you have GCC above 8.0? That seems to be fixed here. Would it be possible to update GTK to version 3.22 or later? It looks like it's possible according to the pacman page.

stuartmorgan commented 5 years ago

If you run that build command manually but use -isystem instead of -I for /usr/include/gtk-3.0 in that build command does the problem go away?

While working on a gn build, I noticed that Chromium's build system processes the pkg-config output to swap in '-isystem' to avoid problems like these, so the general solution may be for us to do the same (which I was planning on doing in a move to gn anyway, but could be done earlier by porting just that script now and having it output in a Make-friendly format for now).

mrhdias commented 5 years ago

I have the last version of gtk3 installed. The output of pkg-config

$ pkg-config --cflags gtk+-3.0 -I/usr/include/gtk-3.0 -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/fribidi -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/harfbuzz -I/usr/include/uuid -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/libdrm -I/usr/include/atk-1.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/at-spi-2.0 -I/usr/include/dbus-1.0 -I/usr/lib/dbus-1.0/include -pthread

$ pkg-config --libs gtk+-3.0 -lgtk-3 -lgdk-3 -lpangocairo-1.0 -lpango-1.0 -latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0

$ pacman -Qi gtk3 Name : gtk3 Version : 3.22.30-1 Description : GObject-based multi-platform GUI toolkit Architecture : x86_64 URL : http://www.gtk.org/ Licenses : LGPL Groups : None Provides : gtk3-print-backends Depends On : atk cairo libxcursor libxinerama libxrandr libxi libepoxy gdk-pixbuf2 dconf libxcomposite libxdamage pango shared-mime-info at-spi2-atk wayland libxkbcommon adwaita-icon-theme json-glib librsvg wayland-protocols desktop-file-utils mesa cantarell-fonts colord rest libcups libcanberra gtk-update-icon-cache Optional Deps : None Required By : aisleriot cheese chrome-remote-desktop chromium clutter evince gcr geany ghex gnome-calculator gnome-desktop gnome-screenshot gtkmm3 gtksourceview3 gtkspell3 gvim gxmessage libgxps lightdm-gtk-greeter notification-daemon opera rawtherapee volumeicon vte3 webkit2gtk wxgtk3 Optional For : avahi ghostscript gvfs libinput opencv qt5-base Conflicts With : gtk3-print-backends Replaces : gtk3-print-backends<=3.22.26-1 Installed Size : 70.03 MiB Packager : Jan Alexander Steffens (heftig) jan.steffens@gmail.com Build Date : Tue 17 Apr 2018 03:50:41 AM WEST Install Date : Tue 17 Apr 2018 10:39:58 AM WEST Install Reason : Installed as a dependency for another package Install Script : Yes Validated By : Signature

mrhdias commented 5 years ago

The suggestion of stuartmorgan work :-)

g++ -std=c++14 -Wall -Werror -shared -fPIC -isystem /usr/include/gtk-3.0 -I../.. -I/home/hdias/Downloads/development/flutter-desktop-embedding/linux/library/include -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/fribidi -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/harfbuzz -I/usr/include/uuid -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/libdrm -I/usr/include/atk-1.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/at-spi-2.0 -I/usr/include/dbus-1.0 -I/usr/lib/dbus-1.0/include -pthread src/json_method_call.cc src/method_result.cc src/json_plugin.cc src/method_codec.cc src/plugin.cc src/internal/text_input_model.cc src/internal/text_input_plugin.cc src/internal/engine_method_result.cc src/internal/plugin_handler.cc src/embedder.cc src/method_call.cc src/json_method_codec.cc -L/home/hdias/Downloads/development/flutter-desktop-embedding/linux/library -lgtk-3 -lgdk-3 -lpangocairo-1.0 -lpango-1.0 -latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0 -lepoxy -lX11 -ljsoncpp -lglfw -lGL -lflutter_engine -Wl,-rpath=/home/hdias/Downloads/development/flutter-desktop-embedding/linux/library -o libflutter_embedder.so

stuartmorgan commented 5 years ago

Thanks for confirming. Taking this bug to track porting Chromium's wrapper script to Dart for eventual use in GN, but with short-term output options for Make.

mrhdias commented 5 years ago

All thing compiles if I replace manually this "-I/usr/include/gtk-3.0" with "-isystem /usr/include/gtk-3.0"

mrhdias commented 5 years ago

I compile the example but not work as expected. Open a window and crash.

$ ./flutter_embedder_example [FATAL:flutter/fml/icu_util.cc(95)] Check failed: context->IsValid(). Must be able to initialize the ICU context. Tried: example/icudtl.dat fish: “./flutter_embedder_example” terminated by signal SIGABRT (Abort)

stuartmorgan commented 5 years ago

That has nothing to do with the warnings, you're just running the example from the wrong directory (see the Linux README about how to run the example, and issue #76 for making it less fragile).

mrhdias commented 5 years ago

Ok, work :-)

$ pwd /home/hdias/development/flutter-desktop-embedding/linux $ ./example/flutter_embedder_example flutter: Observatory listening on http://127.0.0.1:36811/

Is it possible to add the images to flutter-desktop-embedding project to show the developers the appearance of the user interface?

image03 image02 image01

stuartmorgan commented 5 years ago

This is fixed in the GN build, but the script would require extra work to handle Make. I'm not actively working on that, so unassigning.

stuartmorgan commented 5 years ago

Fixed, since GN is now the only build option.