On some architectures it is currently not possible to load separate extensions, because dynamically loaded shared objects cannot reference previously loaded shared objects, and this is alwasy the case with Tcl/Tk extensions. On architectures that support this loading, perform the following steps:
When we install the Tree extension on sparc_sunos5, the tree_wish is produced byc++ -O -I. -Isrc -I/usr/share/common/unsupported/src/tcl/tree-4.0.1/../tk4.0 \ -I/usr/share/common/unsupported/src/tcl/tree-4.0.1/../tcl7.4 \ -I/opt/packages/X11R5/include tkAppInit.o -o tree_wish ./src/libTkTree.a \ -L/ -litcl -L/ -ltclx -L/ -lBLT /opt/unsupported/lib/libtk4.0.a \ /opt/unsupported/lib/libtcl7.4.a -L/opt/packages/X11R5/lib -lX11 -lnsl \ -lsocket -lmwhich we can see when we type make tree_wish. For linking we do not need any of the -I parameters, and since we use the GNU compiler, shared objects are produced by -shared. The Tree initialisation functions are Tree_Init and Dir_Init and their names do not have to be preceded by underscores. Taking all this into account, we can edit the above line to produce tree.so:c++ -shared -o tree.so -u Tree_Init -u Dir_Init ./src/libTkTree.a \ -L/opt/packages/X11R5/lib -lX11 -lnsl -lsocket -lm
A stand-alone initialisation file for the Tree extension would be
As we can see, it is quite similar to the file that uses .o format for dynamic loading and it is thus not very difficult to write system-independent application initialisation files.:- lib(tk). :- load('tree.so'). :- (tcl_interp(I) -> true ; tk([]), % not yet started tcl_interp(I) ), call_c('Tree_Init'(I), _), call_c('Dir_Init'(I), _).