Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 07 Feb 96 16:46:57 -0500
From:      John Robert LoVerso <loverso@osf.org>
To:        John Ousterhout <john.ousterhout@eng.sun.com>
Cc:        jkh@freefall.freebsd.org
Subject:   tcl7.5b1 shared libs patch, message #3
Message-ID:  <199602072146.QAA19943@postman.osf.org>
Resent-Message-ID: <6726.823730720@time.cdrom.com>

next in thread | raw e-mail | index | archive | help
This is the third set of fixes for shared libraries with 7.5b1/4.1b1.

This affects SunOS 5.4, HP-UX 9, FreeBSD 2.1, and probably others.

Basically, you are using explicitly named library files when linking tclsh
and wish.  I.e., this:

	gcc  tclAppInit.o libtcl7.5.so    -lm -o tclsh

Many shared lib implementations record the name of the library, and remember
if it was specified from the library search path via "-l" or given directly.
When given directly, as above, the run time loader attempts to find the
*file*, but it doesn't look in the library path!

Hence, these loads need to be turned into

	gcc  tclAppInit.o -L. -ltcl7.5    -lm -o tclsh

Ditto for wish,
	gcc  tkAppInit.o libtk4.1.so ../../tcl7.5b1/unix/libtcl7.5.so \
		-L/usr/X11R6/lib -lX11  -lm -o wish
should become
	gcc  tkAppInit.o -L. -ltk4.1 -L../../tcl7.5b1/unix -ltcl7.5 \
		-L/usr/X11R6/lib -lX11  -lm -o wish

Ditto for the build of the libtk4.1.so itself.


I ended up doing something like this:

	TCL_LIB = libtcl${_VERSION}${SHLIB_SUFFIX}.1.0
	TCL_LIB_LD = -L. -ltcl${_VERSION}
	...
	${TCL_LIB}: ${OBJS}
		rm -f ${TCL_LIB}
		$(SHLIB_LD) -o ${TCL_LIB} ${OBJS} $(SH_LIBS)

and for Tk:

	TK_LIB = libtk${_VERSION}${SHLIB_SUFFIX}.1.0
	TK_LIB_LD = -L. -ltk${_VERSION}
	...
	LIBS = -L$(TCL_BIN_DIR) -ltcl75 $(X11_LIB_SWITCHES) $(DL_LIBS) -lm 
	...
	${TK_LIB}: $(OBJS)
		rm -f ${TK_LIB}
		$(SHLIB_LD) -o ${TK_LIB} $(OBJS) $(LIBS) 


This brings up the last of the sets of shared library build problems:

SunOS 5.4:
	Tcl's Makefile included this, but Tk's did not:
		LD_FLAGS =  -R ${LIB_INSTALL_DIR}

FreeBSD (and maybe NetBSD, Linux):
	Shared libraries are named as:
		lib<spec>.so.<m>.<n>
	given that m,n are the major/minor revsion of the library.
	Naming the library (as it does by default)
		libtcl7.5.so
	causes the loader to not be able to find the installed lib, since
	it (mistakenly) believes it has major revision of 5!

	The solution is to build it as:
		libtcl75.so.1.0

	This is what I did (above) as it is how the Tcl7.4 "package" installs,
	and it makes the most sense.  Other/Older ways of doing this were:

		libtcl.so.7.5		
			which is how the Tcl7.3 "package" installs
		libtcl.so.75.0
			which is how the TclX7.4 "package" installs

	Hence, ${_VERSION} was 75, verses ${VERSION} of 7.5.

	Without this fix, the compile succeeds on FreeBSD, but the resulting
	binary won't run.

John



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199602072146.QAA19943>