Re: Statically linked GTK app
- From: Raymond Wan <rwan cs mu oz au>
- To: gtk-list gnome org
- Subject: Re: Statically linked GTK app
- Date: Wed, 31 Oct 2001 23:01:54 +1100 (EST)
Hi all,
Sorry for continually asking about this, but this problem has
really stumped me... I've stripped away my code and came up with the
minimum amount of code that will work dynamically but crash statically.
Hopefully, someone can try it out and spot a mistake that I've made in my
code or Makefile. I'm now using GTK v1.3.10 compiled using Christian's
previous posting. There's a Makefile and C source code; both are the
smallest I could make that still duplicates the problem.
Thank you so much!
Ray
=====
CFLAGS = -Wall -g -O3 `pkg-config gtk+-2.0 --cflags`
LDADD = `pkg-config gtk+-2.0 --libs`
all: dynamic static
.c.o:
gcc $(CFLAGS) -c $<
dynamic:
gcc $(CFLAGS) -o dynamic test.c $(LDADD)
static:
gcc $(CFLAGS) -o static test.c $(LDADD) -static
clean:
rm -f static dynamic
=====
#include <gtk/gtk.h>
#include <stdio.h>
#include <stdlib.h>
static char *sample_xpm[] = {
" 2 2 2 1",
"x c #ff0000",
" c None",
"x ",
" x"};
GtkWidget *main_window;
GtkWidget *toolbar;
GtkWidget *result;
static void closeWindow (GtkWidget *widget) {
gtk_widget_destroy (GTK_WIDGET (widget));
return;
}
static GtkWidget *createWidgetFromXpm (GtkWidget *window, gchar **data) {
GdkBitmap *mask;
GdkPixmap *pixmap_data;
GtkWidget *pixmap_widget;
GdkColormap *color_map;
color_map = gtk_widget_get_colormap (GTK_WIDGET (main_window));
fprintf (stderr, "Crashes next line.\n");
pixmap_data = gdk_pixmap_colormap_create_from_xpm_d (main_window ->
window, color_map, &mask, NULL, (gchar**) data);
fprintf (stderr, "It works!\n");
pixmap_widget = gtk_pixmap_new (pixmap_data, mask);
gtk_widget_show (pixmap_widget);
return (pixmap_widget);
}
int main (int argc, char *argv[]) {
gtk_init (&argc, &argv);
main_window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
toolbar = gtk_toolbar_new ();
result = gtk_toolbar_append_item (GTK_TOOLBAR (toolbar), NULL, "Close
window", NULL, createWidgetFromXpm (main_window, (gchar **) sample_xpm),
(GtkSignalFunc) closeWindow, NULL);
gtk_widget_show_all (main_window);
gtk_main ();
return (0);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]