[comp.windows.x] problem mixing compilers

davis@groucho.ucar.edu (Glenn P. Davis) (01/05/90)

Environment: sun3, Sun OS 4.O.3, gcc version 1.36

#define HasGcc YES
#define HasSunOSSharedLibraries YES

When attempting to link simple Xaw programs using the sun cc complier,
referencing system X libs built as above, there are unresovled externals
which are not in gcc-gnulib. Linking with gcc is no problem.

Repeat By:

===== simple make file, test.mk ====
INCLUDES =
DEFINES =
CPPFLAGS = $(INCLUDES) $(DEFINES)

LOADLIBS = -lXaw -lXmu -lXt -lX11

xhw : xhw.o
	$(LINK.c) $(LINKOPTS) xhw.o $(LOADLIBS) -o $@
==== end of test.mk ===


Script started on Thu Jan  4 20:01:55 1990
	(groucho) 94 % pwd
	/u3/X11R4/mit/examples/Xaw
	(groucho) 95 % rm xhw ; make -f test.mk
	cc     -sun3  xhw.o  -lXaw -lXmu -lXt -lX11 -o xhw
	(groucho) 96 % xhw
	ld.so: call to undefined procedure __GetHostname from 0xebc073a
	(groucho) 97 % rm xhw ; make CC=gcc -f test.mk
	gcc     -sun3  xhw.o  -lXaw -lXmu -lXt -lX11 -o xhw
	(groucho) 98 % xhw
		# window apprears as it should
	(groucho) 99 % rm xhw ; make LINKOPTS=-Bstatic -f test.mk
	cc     -sun3 -Bstatic xhw.o  -lXaw -lXmu -lXt -lX11 -o xhw
	Undefined:
	_XrmDestroyDatabase
	__GetHostname
	*** Error code 1
	make: Fatal error: Command failed for target `xhw'
	(groucho) 100 % exit
script done on Thu Jan  4 20:05:42 1990

Note: adding the gnu library, gcc-gnulib, to the end of LOADLIBS,
makes no difference.


Glenn P. Davis
UCAR / Unidata
PO Box 3000                   1685 38th St.
Boulder, CO 80307-3000        Boulder, CO  80301

(303) 497 8643

hvr@kimba.Sun.COM (Heather Rose) (01/06/90)

In article <5896@ncar.ucar.edu> davis@groucho.UCAR.EDU (Glenn P. Davis) writes:
>Environment: sun3, Sun OS 4.O.3, gcc version 1.36
>
>	ld.so: call to undefined procedure __GetHostname from 0xebc073a
>	(groucho) 97 % rm xhw ; make CC=gcc -f test.mk
>	gcc     -sun3  xhw.o  -lXaw -lXmu -lXt -lX11 -o xhw
>	(groucho) 98 % xhw
>		# window apprears as it should
>	(groucho) 99 % rm xhw ; make LINKOPTS=-Bstatic -f test.mk
>	cc     -sun3 -Bstatic xhw.o  -lXaw -lXmu -lXt -lX11 -o xhw
>	Undefined:
>	_XrmDestroyDatabase
>	__GetHostname

I think if you check the value of LD_LIBRARY_PATH, you'll see that you're
mixing OpenWindows libX11 with R4 libX*.

Heather
hrose@sun.com

--------------------------- (repeat by) ----------------------------

1) Checking xnews libraries:

kimba 225> cd /home/xnews/lib
kimba 226> foreach i (lib*)
? echo "nm $i"
? nm $i | egrep "XrmDestroyDatabase|GetHostname" 
? end
nm libX.a
         U __GetHostname
nm libX.sa.0.1
nm libX.so.0.1
nm libX11.a
         U __GetHostname
nm libX11.sa.0.1
nm libX11.so.0.1
nm libX11_p.a
         U __GetHostname
nm libXextent.a
nm libXextent.sa.0.0
nm libXextent.so.0.0
nm libcps.a
nm libcps_g.a
nm libcps_p.a
nm libwire.a
nm libxview.a
nm libxview.sa.2.0
nm libxview.so.2.0
nm libxview_p.a
nm libxvin.a
nm libxvol.a

2) Now checking R4 libraries:

kimba 228> cd /home/X/usr/lib
kimba 229>  foreach i (lib*)
? echo "nm $i"
? nm $i | egrep "XrmDestroyDatabase|GetHostname"
? end
nm libX11.a
         U __XGetHostname
         U __XGetHostname
000018e8 T __XGetHostname
00002718 T _XrmDestroyDatabase
         U __XGetHostname
nm libX11.so.4.2
00020310 T _XrmDestroyDatabase
0001d950 T __XGetHostname
nm libXau.a
nm libXaw.a
nm libXaw.so.4.0
nm libXdmcp.a
nm libXext.a
nm libXinput.a
nm libXmu.a
         U _XmuGetHostname
00000000 T _XmuGetHostname
nm libXmu.sa.4.0
nm libXmu.so.4.0
00003458 T _XmuGetHostname
nm libXt.a
         U _XrmDestroyDatabase
00000000 t __XtGetHostname
nm libXt.sa.4.0
nm libXt.so.4.0
0000c120 t __XtGetHostname
nm liboldX.a
nm liboldX.so.4.0