how to link app against static glib and other dynamic lib which uses gtk?



I have the following grisly situation:

    my_app ------> libglib-2.0.a
         |
         +-------> scratchplot.so --------> libgtk_and_friends.so

I have in my Makefile:

LDLIBS := $(LIBDIR)/asf.a \
          ...
	  $(LIBDIR)/libglib-2.0.a \
	  $(LIBDIR)/libiconv.a \
	  -lm

This target:

test_stamp: test.c
	$(CC) $(CFLAGS) -I$(SCRATCHPLOT_DIR) -c -Wall -g3 -O0 $< 
	$(CC) -Wl,-rpath,$(SCRATCHPLOT_DIR) -L$(SCRATCHPLOT_DIR) test.o \
              $(LDLIBS) -lscratchplot -o test
	./test
	touch $@ 

works fine and the scratchplot test behaves as expected.  If I move the
-lscratchplot to the other side of $(LDLIBS), everything build without
complaint, but then at run time things die:

(stupid_name:11040): Gdk-CRITICAL **: gdk_window_set_title: assertion 
`title != NULL' failed

(stupid_name:11040): Gdk-CRITICAL **: gdk_window_set_title: assertion 
`title != NULL' failed
make: *** [test_drawer_stamp] Segmentation fault (core dumped)

These calls are in gdk_init and gtk_init.  

Unfortunately, for the target that builds my_app (which actually uses glib
directly itself), it doesn't matter where I put -lscratchplot, things die
with the error above at run time.  I guess the problem is that the
staticly linked library (vertion 2.4.7) is somehow getting munged together 
with the dynamic version linked by scratchplot.so (which is version 
2.6.0).  I wouldn't expect these version to be binary compatible in this 
way I guess.  

As I asked above, any hints on how to compile this stuff or pointers to 
relevant bits of gcc documentation would be greatly appreciated.

Thanks,
Britton Kerin




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]