我想在msys2(Windows 7)上创建一个使用Gtk3的GtkPlug的简单程序。 但是我收到了一个链接错误,如下所示。
$ gcc `pkg-config --cflags gtk+-win32-3.0` -o plug plug.c `pkg-config --libs gtk+-win32-3.0`
plug.c: In function 'main': plug.c:22:23: warning: initialization makes pointer from integer without a cast
[enabled by default]
GtkWidget *plug = gtk_plug_new(0);
^
C:\msys32\tmp\ccTQ2pkd.o:plug.c:(.text+0x75): undefined reference to `gtk_plug_new'
C:\msys32\tmp\ccTQ2pkd.o:plug.c:(.text+0x14f): undefined reference to `GTK_PLUG'
C:\msys32\tmp\ccTQ2pkd.o:plug.c:(.text+0x15f): undefined reference to `gtk_plug_add'
collect2.exe: error: ld returned 1 exit status
plug.c
#include <gtk/gtk.h>
static void destroy(GtkWidget *widget, gpointer data)
{
gtk_main_quit();
}
static void embed_event(GtkWidget *widget, gpointer data)
{
g_print("Embed event occurred");
}
static void entry_activated(GtkWidget *widget, gpointer data)
{
g_print("Entry activated");
}
int main(int argc, char *argv[])
{
gtk_init(&argc, &argv);
GtkWidget *plug = gtk_plug_new(0);
g_print("%i", gtk_plug_get_id(GTK_PLUG(plug)));
g_signal_connect(plug, "destroy", G_CALLBACK(destroy), NULL);
g_signal_connect(plug, "embed-event", G_CALLBACK(embed_event), NULL);
GtkWidget *entry = gtk_entry_new();
gtk_entry_set_text(GTK_ENTRY(entry), "Plug and Socket");
g_signal_connect(entry, "activate", G_CALLBACK(entry_activated), NULL);
gtk_plug_add(GTK_PLUG(plug), entry);
gtk_widget_show_all(plug);
gtk_main();
return 0;
}
一个简单的Gtk程序,它不使用我可以制作的GtkPlug。
请有人能给我适当的解决方案吗?