#gcc #gtk
#gcc #gtk
Вопрос:
Я не могу #include <errno.h>
использовать заголовок в своем приложении GTK . Я пробовал как с GTK 2, так и с 3, все еще ошибка.
Если я не включу errno.h
, он скажет, что он не был включен. Однако, если я это сделаю, ld завершится неудачей, сообщив, что ни одна функция из библиотек GTK не была включена.
Журнал компиляции для gtk3 (нет errno)
gcc `pkg-config --cflags --libs gtk -3.0` -o winopa_launcher winopa_launcher.cwinopa_launcher.c: In function ‘on_set_btn_clicked’:
winopa_launcher.c:21:15: warning: assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
21 | entry_value = gtk_entry_get_text(entry);
| ^
winopa_launcher.c:24:37: warning: passing argument 1 of ‘gtk_message_dialog_new’ from incompatible pointer type [-Wincompatible-pointer-types]
24 | dialog = gtk_message_dialog_new(widget, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, ""%s" is not a valid integer", entry_value);
| ^~~~~~
| |
| GtkWidget * {aka struct _GtkWidget *}
In file included from /usr/include/gtk-3.0/gtk/gtk.h:150,
from winopa_launcher.c:1:
/usr/include/gtk-3.0/gtk/gtkmessagedialog.h:99:12: note: expected ‘GtkWindow *’ {aka ‘struct _GtkWindow *’} but argument is of type ‘GtkWidget *’ {aka ‘struct _GtkWidget *’}
99 | GtkWidget* gtk_message_dialog_new (GtkWindow *parent,
| ^~~~~~~~~~~~~~~~~~~~~~
winopa_launcher.c:24:12: warning: assignment to ‘GtkMessageDialog *’ {aka ‘struct _GtkMessageDialog *’} from incompatible pointer type ‘GtkWidget *’ {aka ‘struct _GtkWidget *’} [-Wincompatible-pointer-types]
24 | dialog = gtk_message_dialog_new(widget, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, ""%s" is not a valid integer", entry_value);
| ^
winopa_launcher.c:26:24: warning: passing argument 1 of ‘gtk_widget_destroy’ from incompatible pointer type [-Wincompatible-pointer-types]
26 | gtk_widget_destroy(dialog);
| ^~~~~~
| |
| GtkMessageDialog * {aka struct _GtkMessageDialog *}
In file included from /usr/include/gtk-3.0/gtk/gtkapplication.h:27,
from /usr/include/gtk-3.0/gtk/gtkwindow.h:33,
from /usr/include/gtk-3.0/gtk/gtkdialog.h:32,
from /usr/include/gtk-3.0/gtk/gtkaboutdialog.h:30,
from /usr/include/gtk-3.0/gtk/gtk.h:31,
from winopa_launcher.c:1:
/usr/include/gtk-3.0/gtk/gtkwidget.h:619:50: note: expected ‘GtkWidget *’ {aka ‘struct _GtkWidget *’} but argument is of type ‘GtkMessageDialog *’ {aka ‘struct _GtkMessageDialog *’}
619 | void gtk_widget_destroy (GtkWidget *widget);
| ~~~~~~~~~~~~~~~~~~^~~~~~
winopa_launcher.c:32:37: warning: passing argument 1 of ‘gtk_message_dialog_new’ from incompatible pointer type [-Wincompatible-pointer-types]
32 | dialog = gtk_message_dialog_new(widget, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, "Expected a percentage between 5 and 100");
| ^~~~~~
| |
| GtkWidget * {aka struct _GtkWidget *}
In file included from /usr/include/gtk-3.0/gtk/gtk.h:150,
from winopa_launcher.c:1:
/usr/include/gtk-3.0/gtk/gtkmessagedialog.h:99:12: note: expected ‘GtkWindow *’ {aka ‘struct _GtkWindow *’} but argument is of type ‘GtkWidget *’ {aka ‘struct _GtkWidget *’}
99 | GtkWidget* gtk_message_dialog_new (GtkWindow *parent,
| ^~~~~~~~~~~~~~~~~~~~~~
winopa_launcher.c:32:12: warning: assignment to ‘GtkMessageDialog *’ {aka ‘struct _GtkMessageDialog *’} from incompatible pointer type ‘GtkWidget *’ {aka ‘struct _GtkWidget *’} [-Wincompatible-pointer-types]
32 | dialog = gtk_message_dialog_new(widget, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, "Expected a percentage between 5 and 100");
| ^
winopa_launcher.c:34:24: warning: passing argument 1 of ‘gtk_widget_destroy’ from incompatible pointer type [-Wincompatible-pointer-types]
34 | gtk_widget_destroy(dialog);
| ^~~~~~
| |
| GtkMessageDialog * {aka struct _GtkMessageDialog *}
In file included from /usr/include/gtk-3.0/gtk/gtkapplication.h:27,
from /usr/include/gtk-3.0/gtk/gtkwindow.h:33,
from /usr/include/gtk-3.0/gtk/gtkdialog.h:32,
from /usr/include/gtk-3.0/gtk/gtkaboutdialog.h:30,
from /usr/include/gtk-3.0/gtk/gtk.h:31,
from winopa_launcher.c:1:
/usr/include/gtk-3.0/gtk/gtkwidget.h:619:50: note: expected ‘GtkWidget *’ {aka ‘struct _GtkWidget *’} but argument is of type ‘GtkMessageDialog *’ {aka ‘struct _GtkMessageDialog *’}
619 | void gtk_widget_destroy (GtkWidget *widget);
| ~~~~~~~~~~~~~~~~~~^~~~~~
winopa_launcher.c:41:156: error: ‘g_errno’ undeclared (first use in this function); did you mean ‘g_error’?
41 | GE_ERROR, GTK_BUTTONS_CLOSE, "Could not execute command. [Errno %d]", g_errno);
| ^~~~~~~
| g_error
winopa_launcher.c:41:156: note: each undeclared identifier is reported only once for each function it appears in
winopa_launcher.c:41:37: warning: passing argument 1 of ‘gtk_message_dialog_new’ from incompatible pointer type [-Wincompatible-pointer-types]
41 | dialog = gtk_message_dialog_new(widget, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, "Could not execute command. [Errno %d]", g_errno);
| ^~~~~~
| |
| GtkWidget * {aka struct _GtkWidget *}
In file included from /usr/include/gtk-3.0/gtk/gtk.h:150,
from winopa_launcher.c:1:
/usr/include/gtk-3.0/gtk/gtkmessagedialog.h:99:12: note: expected ‘GtkWindow *’ {aka ‘struct _GtkWindow *’} but argument is of type ‘GtkWidget *’ {aka ‘struct _GtkWidget *’}
99 | GtkWidget* gtk_message_dialog_new (GtkWindow *parent,
| ^~~~~~~~~~~~~~~~~~~~~~
winopa_launcher.c:43:24: warning: passing argument 1 of ‘gtk_widget_destroy’ from incompatible pointer type [-Wincompatible-pointer-types]
43 | gtk_widget_destroy(dialog);
| ^~~~~~
| |
| GtkMessageDialog * {aka struct _GtkMessageDialog *}
In file included from /usr/include/gtk-3.0/gtk/gtkapplication.h:27,
from /usr/include/gtk-3.0/gtk/gtkwindow.h:33,
from /usr/include/gtk-3.0/gtk/gtkdialog.h:32,
from /usr/include/gtk-3.0/gtk/gtkaboutdialog.h:30,
from /usr/include/gtk-3.0/gtk/gtk.h:31,
from winopa_launcher.c:1:
/usr/include/gtk-3.0/gtk/gtkwidget.h:619:50: note: expected ‘GtkWidget *’ {aka ‘struct _GtkWidget *’} but argument is of type ‘GtkMessageDialog *’ {aka ‘struct _GtkMessageDialog *’}
619 | void gtk_widget_destroy (GtkWidget *widget);
| ~~~~~~~~~~~~~~~~~~^~~~~~
winopa_launcher.c: In function ‘main’:
winopa_launcher.c:59:3: warning: ‘gtk_vbox_new’ is deprecated: Use 'gtk_box_new' instead [-Wdeprecated-declarations]
59 | vbox = gtk_vbox_new(TRUE, 5);
| ^~~~
In file included from /usr/include/gtk-3.0/gtk/gtk.h:286,
from winopa_launcher.c:1:
/usr/include/gtk-3.0/gtk/deprecated/gtkvbox.h:61:13: note: declared here
61 | GtkWidget * gtk_vbox_new (gboolean homogeneous,
| ^~~~~~~~~~~~
winopa_launcher.c:64:3: warning: ‘gtk_hbox_new’ is deprecated: Use 'gtk_box_new' instead [-Wdeprecated-declarations]
64 | hbox = gtk_hbox_new(TRUE, 5);
| ^~~~
In file included from /usr/include/gtk-3.0/gtk/gtk.h:262,
from winopa_launcher.c:1:
/usr/include/gtk-3.0/gtk/deprecated/gtkhbox.h:63:13: note: declared here
63 | GtkWidget * gtk_hbox_new (gboolean homogeneous,
| ^~~~~~~~~~~~
mattia@mattia-ThinkPad-E595:~/lab$ gtk3-gcc -o winopa_launcher winopa_launcher.c
winopa_launcher.c: In function ‘on_set_btn_clicked’:
winopa_launcher.c:25:12: warning: assignment to ‘GtkMessageDialog *’ {aka ‘struct _GtkMessageDialog *’} from incompatible pointer type ‘GtkWidget *’ {aka ‘struct _GtkWidget *’} [-Wincompatible-pointer-types]
25 | dialog = gtk_message_dialog_new(GTK_WINDOW(widget), GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, ""%s" is not a valid integer", entry_value);
| ^
winopa_launcher.c:33:37: warning: passing argument 1 of ‘gtk_message_dialog_new’ from incompatible pointer type [-Wincompatible-pointer-types]
33 | dialog = gtk_message_dialog_new(widget, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, "Expected a percentage between 5 and 100");
| ^~~~~~
| |
| GtkWidget * {aka struct _GtkWidget *}
In file included from /usr/include/gtk-3.0/gtk/gtk.h:150,
from winopa_launcher.c:1:
/usr/include/gtk-3.0/gtk/gtkmessagedialog.h:99:12: note: expected ‘GtkWindow *’ {aka ‘struct _GtkWindow *’} but argument is of type ‘GtkWidget *’ {aka ‘struct _GtkWidget *’}
99 | GtkWidget* gtk_message_dialog_new (GtkWindow *parent,
| ^~~~~~~~~~~~~~~~~~~~~~
winopa_launcher.c:33:12: warning: assignment to ‘GtkMessageDialog *’ {aka ‘struct _GtkMessageDialog *’} from incompatible pointer type ‘GtkWidget *’ {aka ‘struct _GtkWidget *’} [-Wincompatible-pointer-types]
33 | dialog = gtk_message_dialog_new(widget, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, "Expected a percentage between 5 and 100");
| ^
winopa_launcher.c:39:12: warning: passing argument 1 of ‘snprintf’ from incompatible pointer type [-Wincompatible-pointer-types]
39 | snprintf(hexvalue, 10, "0x%x", 0xffffffff * value / 100);
| ^~~~~~~~
| |
| char **
In file included from /usr/include/pango-1.0/pango/pango-utils.h:25,
from /usr/include/pango-1.0/pango/pango.h:47,
from /usr/include/gtk-3.0/gdk/gdktypes.h:35,
from /usr/include/gtk-3.0/gdk/gdkapplaunchcontext.h:30,
from /usr/include/gtk-3.0/gdk/gdk.h:32,
from /usr/include/gtk-3.0/gtk/gtk.h:30,
from winopa_launcher.c:1:
/usr/include/stdio.h:354:39: note: expected ‘char * restrict’ but argument is of type ‘char **’
354 | extern int snprintf (char *__restrict __s, size_t __maxlen,
| ~~~~~~~~~~~~~~~~~^~~
winopa_launcher.c:42:156: error: ‘errno’ undeclared (first use in this function)
42 | GTK_BUTTONS_CLOSE, "Could not execute command. [Errno %d]", errno);
| ^~~~~
winopa_launcher.c:2:1: note: ‘errno’ is defined in header ‘<errno.h>’; did you forget to ‘#include <errno.h>’?
1 | #include <gtk/gtk.h>
| #include <errno.h>
2 |
winopa_launcher.c:42:156: note: each undeclared identifier is reported only once for each function it appears in
42 | GTK_BUTTONS_CLOSE, "Could not execute command. [Errno %d]", errno);
| ^~~~~
winopa_launcher.c:42:37: warning: passing argument 1 of ‘gtk_message_dialog_new’ from incompatible pointer type [-Wincompatible-pointer-types]
42 | dialog = gtk_message_dialog_new(widget, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, "Could not execute command. [Errno %d]", errno);
| ^~~~~~
| |
| GtkWidget * {aka struct _GtkWidget *}
In file included from /usr/include/gtk-3.0/gtk/gtk.h:150,
from winopa_launcher.c:1:
/usr/include/gtk-3.0/gtk/gtkmessagedialog.h:99:12: note: expected ‘GtkWindow *’ {aka ‘struct _GtkWindow *’} but argument is of type ‘GtkWidget *’ {aka ‘struct _GtkWidget *’}
99 | GtkWidget* gtk_message_dialog_new (GtkWindow *parent,
| ^~~~~~~~~~~~~~~~~~~~~~
winopa_launcher.c: In function ‘main’:
winopa_launcher.c:60:3: warning: ‘gtk_vbox_new’ is deprecated: Use 'gtk_box_new' instead [-Wdeprecated-declarations]
60 | vbox = gtk_vbox_new(TRUE, 5);
| ^~~~
In file included from /usr/include/gtk-3.0/gtk/gtk.h:286,
from winopa_launcher.c:1:
/usr/include/gtk-3.0/gtk/deprecated/gtkvbox.h:61:13: note: declared here
61 | GtkWidget * gtk_vbox_new (gboolean homogeneous,
| ^~~~~~~~~~~~
winopa_launcher.c:65:3: warning: ‘gtk_hbox_new’ is deprecated: Use 'gtk_box_new' instead [-Wdeprecated-declarations]
65 | hbox = gtk_hbox_new(TRUE, 5);
| ^~~~
In file included from /usr/include/gtk-3.0/gtk/gtk.h:262,
from winopa_launcher.c:1:
/usr/include/gtk-3.0/gtk/deprecated/gtkhbox.h:63:13: note: declared here
63 | GtkWidget * gtk_hbox_new (gboolean homogeneous,
| ^~~~~~~~~~~~
mattia@mattia-ThinkPad-E595:~/lab$ gtk3-gcc -o winopa_launcher winopa_launcher.c
winopa_launcher.c: In function ‘on_set_btn_clicked’:
winopa_launcher.c:25:12: warning: assignment to ‘GtkMessageDialog *’ {aka ‘struct _GtkMessageDialog *’} from incompatible pointer type ‘GtkWidget *’ {aka ‘struct _GtkWidget *’} [-Wincompatible-pointer-types]
25 | dialog = gtk_message_dialog_new(GTK_WINDOW(widget), GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, ""%s" is not a valid integer", entry_value);
| ^
winopa_launcher.c:33:37: warning: passing argument 1 of ‘gtk_message_dialog_new’ from incompatible pointer type [-Wincompatible-pointer-types]
33 | dialog = gtk_message_dialog_new(widget, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, "Expected a percentage between 5 and 100");
| ^~~~~~
| |
| GtkWidget * {aka struct _GtkWidget *}
In file included from /usr/include/gtk-3.0/gtk/gtk.h:150,
from winopa_launcher.c:1:
/usr/include/gtk-3.0/gtk/gtkmessagedialog.h:99:12: note: expected ‘GtkWindow *’ {aka ‘struct _GtkWindow *’} but argument is of type ‘GtkWidget *’ {aka ‘struct _GtkWidget *’}
99 | GtkWidget* gtk_message_dialog_new (GtkWindow *parent,
| ^~~~~~~~~~~~~~~~~~~~~~
winopa_launcher.c:33:12: warning: assignment to ‘GtkMessageDialog *’ {aka ‘struct _GtkMessageDialog *’} from incompatible pointer type ‘GtkWidget *’ {aka ‘struct _GtkWidget *’} [-Wincompatible-pointer-types]
33 | dialog = gtk_message_dialog_new(widget, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, "Expected a percentage between 5 and 100");
| ^
winopa_launcher.c:39:12: warning: passing argument 1 of ‘snprintf’ from incompatible pointer type [-Wincompatible-pointer-types]
39 | snprintf(hexvalue, 10, "0x%x", 0xffffffff * value / 100);
| ^~~~~~~~
| |
| char **
In file included from /usr/include/pango-1.0/pango/pango-utils.h:25,
from /usr/include/pango-1.0/pango/pango.h:47,
from /usr/include/gtk-3.0/gdk/gdktypes.h:35,
from /usr/include/gtk-3.0/gdk/gdkapplaunchcontext.h:30,
from /usr/include/gtk-3.0/gdk/gdk.h:32,
from /usr/include/gtk-3.0/gtk/gtk.h:30,
from winopa_launcher.c:1:
/usr/include/stdio.h:354:39: note: expected ‘char * restrict’ but argument is of type ‘char **’
354 | extern int snprintf (char *__restrict __s, size_t __maxlen,
| ~~~~~~~~~~~~~~~~~^~~
winopa_launcher.c:42:156: error: ‘errno’ undeclared (first use in this function)
42 | GTK_BUTTONS_CLOSE, "Could not execute command. [Errno %d]", errno);
| ^~~~~
winopa_launcher.c:2:1: note: ‘errno’ is defined in header ‘<errno.h>’; did you forget to ‘#include <errno.h>’?
1 | #include <gtk/gtk.h>
| #include <errno.h>
2 |
winopa_launcher.c:42:156: note: each undeclared identifier is reported only once for each function it appears in
42 | GTK_BUTTONS_CLOSE, "Could not execute command. [Errno %d]", errno);
| ^~~~~
winopa_launcher.c:42:37: warning: passing argument 1 of ‘gtk_message_dialog_new’ from incompatible pointer type [-Wincompatible-pointer-types]
42 | dialog = gtk_message_dialog_new(widget, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, "Could not execute command. [Errno %d]", errno);
| ^~~~~~
| |
| GtkWidget * {aka struct _GtkWidget *}
In file included from /usr/include/gtk-3.0/gtk/gtk.h:150,
from winopa_launcher.c:1:
/usr/include/gtk-3.0/gtk/gtkmessagedialog.h:99:12: note: expected ‘GtkWindow *’ {aka ‘struct _GtkWindow *’} but argument is of type ‘GtkWidget *’ {aka ‘struct _GtkWidget *’}
99 | GtkWidget* gtk_message_dialog_new (GtkWindow *parent,
| ^~~~~~~~~~~~~~~~~~~~~~
winopa_launcher.c: In function ‘main’:
winopa_launcher.c:60:3: warning: ‘gtk_vbox_new’ is deprecated: Use 'gtk_box_new' instead [-Wdeprecated-declarations]
60 | vbox = gtk_vbox_new(TRUE, 5);
| ^~~~
In file included from /usr/include/gtk-3.0/gtk/gtk.h:286,
from winopa_launcher.c:1:
/usr/include/gtk-3.0/gtk/deprecated/gtkvbox.h:61:13: note: declared here
61 | GtkWidget * gtk_vbox_new (gboolean homogeneous,
| ^~~~~~~~~~~~
winopa_launcher.c:65:3: warning: ‘gtk_hbox_new’ is deprecated: Use 'gtk_box_new' instead [-Wdeprecated-declarations]
65 | hbox = gtk_hbox_new(TRUE, 5);
| ^~~~
In file included from /usr/include/gtk-3.0/gtk/gtk.h:262,
from winopa_launcher.c:1:
/usr/include/gtk-3.0/gtk/deprecated/gtkhbox.h:63:13: note: declared here
63 | GtkWidget * gtk_hbox_new (gboolean homogeneous,
| ^~~~~~~~~~~~
Журнал компиляции из gtk3 (с errno):
$ gcc `pkg-config --cflags --libs gtk -3.0` -o winopa_launcher winopa_launcher.c
winopa_launcher.c: In function ‘on_set_btn_clicked’:
winopa_launcher.c:26:12: warning: assignment to ‘GtkMessageDialog *’ {aka ‘struct _GtkMessageDialog *’} from incompatible pointer type ‘GtkWidget *’ {aka ‘struct _GtkWidget *’} [-Wincompatible-pointer-types]
26 | dialog = gtk_message_dialog_new(GTK_WINDOW(widget), GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, ""%s" is not a valid integer", entry_value);
| ^
winopa_launcher.c:34:37: warning: passing argument 1 of ‘gtk_message_dialog_new’ from incompatible pointer type [-Wincompatible-pointer-types]
34 | dialog = gtk_message_dialog_new(widget, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, "Expected a percentage between 5 and 100");
| ^~~~~~
| |
| GtkWidget * {aka struct _GtkWidget *}
In file included from /usr/include/gtk-3.0/gtk/gtk.h:150,
from winopa_launcher.c:1:
/usr/include/gtk-3.0/gtk/gtkmessagedialog.h:99:12: note: expected ‘GtkWindow *’ {aka ‘struct _GtkWindow *’} but argument is of type ‘GtkWidget *’ {aka ‘struct _GtkWidget *’}
99 | GtkWidget* gtk_message_dialog_new (GtkWindow *parent,
| ^~~~~~~~~~~~~~~~~~~~~~
winopa_launcher.c:34:12: warning: assignment to ‘GtkMessageDialog *’ {aka ‘struct _GtkMessageDialog *’} from incompatible pointer type ‘GtkWidget *’ {aka ‘struct _GtkWidget *’} [-Wincompatible-pointer-types]
34 | dialog = gtk_message_dialog_new(widget, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, "Expected a percentage between 5 and 100");
| ^
winopa_launcher.c:40:12: warning: passing argument 1 of ‘snprintf’ from incompatible pointer type [-Wincompatible-pointer-types]
40 | snprintf(hexvalue, 10, "0x%x", 0xffffffff * value / 100);
| ^~~~~~~~
| |
| char **
In file included from /usr/include/pango-1.0/pango/pango-utils.h:25,
from /usr/include/pango-1.0/pango/pango.h:47,
from /usr/include/gtk-3.0/gdk/gdktypes.h:35,
from /usr/include/gtk-3.0/gdk/gdkapplaunchcontext.h:30,
from /usr/include/gtk-3.0/gdk/gdk.h:32,
from /usr/include/gtk-3.0/gtk/gtk.h:30,
from winopa_launcher.c:1:
/usr/include/stdio.h:354:39: note: expected ‘char * restrict’ but argument is of type ‘char **’
354 | extern int snprintf (char *__restrict __s, size_t __maxlen,
| ~~~~~~~~~~~~~~~~~^~~
winopa_launcher.c:43:37: warning: passing argument 1 of ‘gtk_message_dialog_new’ from incompatible pointer type [-Wincompatible-pointer-types]
43 | dialog = gtk_message_dialog_new(widget, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, "Could not execute command. [Errno %d]", errno);
| ^~~~~~
| |
| GtkWidget * {aka struct _GtkWidget *}
In file included from /usr/include/gtk-3.0/gtk/gtk.h:150,
from winopa_launcher.c:1:
/usr/include/gtk-3.0/gtk/gtkmessagedialog.h:99:12: note: expected ‘GtkWindow *’ {aka ‘struct _GtkWindow *’} but argument is of type ‘GtkWidget *’ {aka ‘struct _GtkWidget *’}
99 | GtkWidget* gtk_message_dialog_new (GtkWindow *parent,
| ^~~~~~~~~~~~~~~~~~~~~~
winopa_launcher.c:43:12: warning: assignment to ‘GtkMessageDialog *’ {aka ‘struct _GtkMessageDialog *’} from incompatible pointer type ‘GtkWidget *’ {aka ‘struct _GtkWidget *’} [-Wincompatible-pointer-types]
43 | dialog = gtk_message_dialog_new(widget, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, "Could not execute command. [Errno %d]", errno);
| ^
winopa_launcher.c: In function ‘main’:
winopa_launcher.c:61:3: warning: ‘gtk_vbox_new’ is deprecated: Use 'gtk_box_new' instead [-Wdeprecated-declarations]
61 | vbox = gtk_vbox_new(TRUE, 5);
| ^~~~
In file included from /usr/include/gtk-3.0/gtk/gtk.h:286,
from winopa_launcher.c:1:
/usr/include/gtk-3.0/gtk/deprecated/gtkvbox.h:61:13: note: declared here
61 | GtkWidget * gtk_vbox_new (gboolean homogeneous,
| ^~~~~~~~~~~~
winopa_launcher.c:66:3: warning: ‘gtk_hbox_new’ is deprecated: Use 'gtk_box_new' instead [-Wdeprecated-declarations]
66 | hbox = gtk_hbox_new(TRUE, 5);
| ^~~~
In file included from /usr/include/gtk-3.0/gtk/gtk.h:262,
from winopa_launcher.c:1:
/usr/include/gtk-3.0/gtk/deprecated/gtkhbox.h:63:13: note: declared here
63 | GtkWidget * gtk_hbox_new (gboolean homogeneous,
| ^~~~~~~~~~~~
/usr/bin/ld: /tmp/ccrQ0vyC.o: in function `destroy':
winopa_launcher.c:(.text 0x21): undefined reference to `g_print'
/usr/bin/ld: winopa_launcher.c:(.text 0x26): undefined reference to `gtk_main_quit'
/usr/bin/ld: /tmp/ccrQ0vyC.o: in function `on_set_btn_clicked':
winopa_launcher.c:(.text 0x6c): undefined reference to `gtk_entry_get_text'
/usr/bin/ld: winopa_launcher.c:(.text 0xad): undefined reference to `g_print'
/usr/bin/ld: winopa_launcher.c:(.text 0xb2): undefined reference to `gtk_window_get_type'
/usr/bin/ld: winopa_launcher.c:(.text 0xc7): undefined reference to `g_type_check_instance_cast'
/usr/bin/ld: winopa_launcher.c:(.text 0xf1): undefined reference to `gtk_message_dialog_new'
/usr/bin/ld: winopa_launcher.c:(.text 0xfa): undefined reference to `gtk_dialog_get_type'
/usr/bin/ld: winopa_launcher.c:(.text 0x10c): undefined reference to `g_type_check_instance_cast'
/usr/bin/ld: winopa_launcher.c:(.text 0x114): undefined reference to `gtk_dialog_run'
/usr/bin/ld: winopa_launcher.c:(.text 0x119): undefined reference to `gtk_widget_get_type'
/usr/bin/ld: winopa_launcher.c:(.text 0x12b): undefined reference to `g_type_check_instance_cast'
/usr/bin/ld: winopa_launcher.c:(.text 0x133): undefined reference to `gtk_widget_destroy'
/usr/bin/ld: winopa_launcher.c:(.text 0x162): undefined reference to `g_print'
/usr/bin/ld: winopa_launcher.c:(.text 0x18c): undefined reference to `gtk_message_dialog_new'
/usr/bin/ld: winopa_launcher.c:(.text 0x195): undefined reference to `gtk_dialog_get_type'
/usr/bin/ld: winopa_launcher.c:(.text 0x1a7): undefined reference to `g_type_check_instance_cast'
/usr/bin/ld: winopa_launcher.c:(.text 0x1af): undefined reference to `gtk_dialog_run'
/usr/bin/ld: winopa_launcher.c:(.text 0x1b4): undefined reference to `gtk_widget_get_type'
/usr/bin/ld: winopa_launcher.c:(.text 0x1c6): undefined reference to `g_type_check_instance_cast'
/usr/bin/ld: winopa_launcher.c:(.text 0x1ce): undefined reference to `gtk_widget_destroy'
/usr/bin/ld: winopa_launcher.c:(.text 0x291): undefined reference to `gtk_message_dialog_new'
/usr/bin/ld: winopa_launcher.c:(.text 0x29a): undefined reference to `gtk_dialog_get_type'
/usr/bin/ld: winopa_launcher.c:(.text 0x2ac): undefined reference to `g_type_check_instance_cast'
/usr/bin/ld: winopa_launcher.c:(.text 0x2b4): undefined reference to `gtk_dialog_run'
/usr/bin/ld: winopa_launcher.c:(.text 0x2b9): undefined reference to `gtk_widget_get_type'
/usr/bin/ld: winopa_launcher.c:(.text 0x2cb): undefined reference to `g_type_check_instance_cast'
/usr/bin/ld: winopa_launcher.c:(.text 0x2d3): undefined reference to `gtk_widget_destroy'
/usr/bin/ld: /tmp/ccrQ0vyC.o: in function `main':
winopa_launcher.c:(.text 0x316): undefined reference to `gtk_init'
/usr/bin/ld: winopa_launcher.c:(.text 0x320): undefined reference to `gtk_window_new'
/usr/bin/ld: winopa_launcher.c:(.text 0x34f): undefined reference to `g_signal_connect_data'
/usr/bin/ld: winopa_launcher.c:(.text 0x362): undefined reference to `gtk_window_set_title'
/usr/bin/ld: winopa_launcher.c:(.text 0x371): undefined reference to `gtk_vbox_new'
/usr/bin/ld: winopa_launcher.c:(.text 0x381): undefined reference to `gtk_label_new'
/usr/bin/ld: winopa_launcher.c:(.text 0x38a): undefined reference to `gtk_box_get_type'
/usr/bin/ld: winopa_launcher.c:(.text 0x39c): undefined reference to `g_type_check_instance_cast'
/usr/bin/ld: winopa_launcher.c:(.text 0x3bb): undefined reference to `gtk_box_pack_end'
/usr/bin/ld: winopa_launcher.c:(.text 0x3ca): undefined reference to `gtk_hbox_new'
/usr/bin/ld: winopa_launcher.c:(.text 0x3d3): undefined reference to `gtk_entry_new'
/usr/bin/ld: winopa_launcher.c:(.text 0x3dc): undefined reference to `gtk_entry_get_type'
/usr/bin/ld: winopa_launcher.c:(.text 0x3ee): undefined reference to `g_type_check_instance_cast'
/usr/bin/ld: winopa_launcher.c:(.text 0x3fd): undefined reference to `gtk_entry_set_text'
/usr/bin/ld: winopa_launcher.c:(.text 0x402): undefined reference to `gtk_box_get_type'
/usr/bin/ld: winopa_launcher.c:(.text 0x414): undefined reference to `g_type_check_instance_cast'
/usr/bin/ld: winopa_launcher.c:(.text 0x433): undefined reference to `gtk_box_pack_end'
/usr/bin/ld: winopa_launcher.c:(.text 0x43f): undefined reference to `gtk_button_new_with_label'
/usr/bin/ld: winopa_launcher.c:(.text 0x448): undefined reference to `gtk_box_get_type'
/usr/bin/ld: winopa_launcher.c:(.text 0x45a): undefined reference to `g_type_check_instance_cast'
/usr/bin/ld: winopa_launcher.c:(.text 0x479): undefined reference to `gtk_box_pack_end'
/usr/bin/ld: winopa_launcher.c:(.text 0x47e): undefined reference to `gtk_box_get_type'
/usr/bin/ld: winopa_launcher.c:(.text 0x490): undefined reference to `g_type_check_instance_cast'
/usr/bin/ld: winopa_launcher.c:(.text 0x4af): undefined reference to `gtk_box_pack_end'
/usr/bin/ld: winopa_launcher.c:(.text 0x4b4): undefined reference to `gtk_container_get_type'
/usr/bin/ld: winopa_launcher.c:(.text 0x4c6): undefined reference to `g_type_check_instance_cast'
/usr/bin/ld: winopa_launcher.c:(.text 0x4d8): undefined reference to `gtk_container_add'
/usr/bin/ld: winopa_launcher.c:(.text 0x4e4): undefined reference to `gtk_widget_show_all'
/usr/bin/ld: winopa_launcher.c:(.text 0x4e9): undefined reference to `gtk_main'
collect2: error: ld returned 1 exit status
То же самое для gtk2.
Я не нашел никакого решения в Интернете. Я запускаю Ubuntu 20.04 с gcc 9.3.0 и GTK из недавно установленных основных репозиториев Ubuntu apt.
РЕДАКТИРОВАТЬ: после закомментирования фрагмента кода, содержащего errno, я обнаружил, что это не проблема errno.h
. Проблема в самом gtk. Но все равно получаю много ужасных предупреждений, и мне лень вставлять все соответствующие приведения типов.
Ответ №1:
РЕШЕНО!
Проблема в аргументах командной строки. Я ставил телегу впереди лошади. Флаги ВСЕГДА должны следовать за всеми другими аргументами.
Перемещение
$ gcc `pkg-config --libs --cflags gtk -3.0` -o winopa_launcher winopa_launcher.c
Для
$ gcc -o winopa_launcher winopa_launcher.c `pkg-config --libs --cflags gtk -3.0`
может решить проблему.