Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
3.4k views
in Technique[技术] by (71.8m points)

c - Getting a Segmentation fault (core dumped) message when trying to execute my gui program

Here is my code right now

#include <stdlib.h>
#include <sys/types.h>
#include <signal.h>
#include <unistd.h>
#include <string.h>
#include <gtk/gtk.h>
#include <gtk/gtkx.h>
#include <math.h>
#include <time.h>
#include <ctype.h>

GtkWidget* window;
GtkWidget* fixed;
GtkWidget* menu;
GtkWidget* file;
GtkWidget* open;
GtkBuilder* builder;

int main(int argc, char* argv[]) {

        gtk_init(&argc, &argv);
        builder = gtk_builder_new_from_file("gui.glade");
        window = GTK_WIDGET(gtk_builder_get_object(builder, "window"));
        g_signal_connect(window, "destroy", G_CALLBACK(gtk_main_quit), NULL);
        gtk_builder_connect_signals(builder, NULL);

        fixed = GTK_WIDGET(gtk_builder_get_object(builder, "fixed"));
        menu = GTK_WIDGET(gtk_builder_get_object(builder, "menu"));
        file = GTK_WIDGET(gtk_builder_get_object(builder, "file"));
        open = GTK_WIDGET(gtk_builder_get_object(builder, "open"));

        gtk_widget_show(window);
        gtk_main();

        return EXIT_SUCCESS;
}

If I remove the initialization for the widget open and the statement where I pull it out from builder, the program executes fine but with it in there I get the Segmentation fault. I tried stepping through it with gdb, but it hasn't helped.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神解答

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...