编译

时间:2015-11-05 15:14:59

标签: c ubuntu gtk

我正在使用ubuntu 14.04,我有来自here的以下程序:

    #include <gtk/gtk.h>

    static void
    activate (GtkApplication* app,
            gpointer        user_data)
    {
        GtkWidget *window;

        window = gtk_application_window_new (app);
        gtk_window_set_title (GTK_WINDOW (window), "Window");
        gtk_window_set_default_size (GTK_WINDOW (window), 200, 200);
        gtk_widget_show_all (window);
    }

    int
    main (int    argc,
            char **argv)
    {
        GtkApplication *app;
        int status;

        app = gtk_application_new ("org.gtk.example", G_APPLICATION_FLAGS_NONE);
        g_signal_connect (app, "activate", G_CALLBACK (activate), NULL);
        status = g_application_run (G_APPLICATION (app), argc, argv);
        g_object_unref (app);

        return status;
    }

我用以下代码编译它:

    $ gcc `pkg-config --cflags gtk+-3.0` -o example-0 example-0.c `pkg-config --libs gtk+-3.0`

一切顺利,直到我跑

    $ ./example-0

我得到了结果:

    (example-0:12451): Gtk-ERROR **: GTK+ 2.x symbols detected. Using GTK+ 2.x and GTK+ 3 in the same process is not supported
    Trace/breakpoint trap (core dumped)

我在安装gtk + -3.0之前安装了gtk + -2.0,在报告错误后,我通过以下命令删除了gtk + -2.0:

    $ sudo apt-get purge libgtk-2-dev
    $ sudo apt-get autoremove libgtk-2-dev

但这没有帮助,现在如何解决问题。

0 个答案:

没有答案