[R-gui] Re: [MACTCL] Re: X11 Tktable SUCCESS!!! (fwd)

James Wettenhall wettenhall at wehi.edu.au
Tue Sep 2 01:15:34 MEST 2003


Hi,

After a few failed attempts, I finally got the Tktable 
extension working in R on MacOS X, and I even did it without 
a root password ;-)  I can write these instructions out more 
clearly later on, but if you're interested now, read on...

After advice from Jan de Leeuw on
http://lists.sourceforge.net/lists/listinfo/tcl-mac
I learnt that if you want to use R/TclTk on MacOS X you have 
to choose between Aqua and X11.  RAqua is still quite new, and 
may not work reliably with TkAqua until R 1.8.0 in October.  You 
can download an X11/Darwin compatible R 1.7.0 or 1.7.1 from 
Jan's webpage:
http://gifi.stat.ucla.edu/pub/index.php

The R 1.7.0 is nice, because it comes bundled with lots of 
extra R packages as well as base, so I chose this version.

You can get X11 from
http://www.apple.com/macosx/x11/download/

R 1.7.0 uses fink (a package manager which puts packages in 
/sw/
("software") ) but R 1.7.1 does not.

I think you need the Apple Developer Tools to run fink.  
You certainly need them to build Tktable from source.  A
MacOS X machine should come with a Developer Tools CD.  
This gives you gcc (C compiler) etc.  See:
http://developer.apple.com/tools/

The important thing to realize is that Aqua Tcl/Tk and X11
Tcl/Tk are NOT compatible with each other.  If you 
accidentally combine them, you can get strange errors like:
  Unknown color name "systemWindowBody"

If you want X11 versions of tcl/tk, you can install them 
using fink (a package manager) :
http://fink.sourceforge.net
and this will (by default) put tcl and tk in
/sw/lib/

Then from R, if you type
> library(tcltk)
> tclvalue("auto_path")
[1] "/sw/lib/tcl8.4 /sw/lib ./lib /sw/lib/tk8.4 
/usr/local/lib/R/library/tcltk/exec"

you should see only X11-compatible tcl/tk directories, where 
the "sw" ("software") directories have been installed by fink.

If you make the mistake I made:
> addTclPath("/Library/Tcl")          (WRONG!!!)

then you will probably be adding Aqua Tcl/Tk to the search 
path, which can lead to strange errors.

So to build an X11-compatible Tktable binary (not available 
in fink yet), I downloaded the Tktable source from :
http://tktable.sourceforge.net/
and downloaded the tcl and tk source from :
http://www.tcl.tk/
and downloaded X11 source from :
http://developer.apple.com/darwin/projects/X11/index.html
Maybe the Apple X11 SDK would have been easier. See:
http://www.apple.com/macosx/x11/download/
(bottom right-hand corner of webpage)
but it required a root password to install, so
I built the X11 source instead.

I unzipped and untarred the source packages into:
/Users/guest/tcltk/tcl8.4.4/
/Users/guest/tcltk/tk8.4.4/
/Users/guest/tcltk/Tktable2.8/
/Users/guest/X11ForMacOSXSource-wwdc/

X11 was easy to build with
make
which I ran from the directory 
/Users/guest/X11ForMacOSXSource-wwdc/xc/
but it took a very long time!!!

tcl and tk were also easy to build with
make 
run from within the directories:
/Users/guest/tcltk/tcl8.4.4/macosx/
and
/Users/guest/tcltk/tk8.4.4/macosx/
respectively.
tcl and tk also took a long time to build,  but they were 
quicker than X11.   

Results of the tcl and tk builds appeared in :
/Users/guest/tcltk/build/


Here is the configure command I used inside the directory
/Users/guest/tcltk/Tktable2.8/    

./configure --prefix=/sw --with-tcl=/sw/lib \
--with-tk=/sw/lib \
--with-tclinclude=/Users/guest/tcltk/tcl8.4.4 \
--with-tkinclude=/Users/guest/tcltk/tk8.4.4

[ If fink had installed source as well as binaries in 
/sw/ I might not have needed the --with-tclinclude and 
--with-tkinclude options. ]

Rather than edit the X11 paths in the configure script, I 
just ran make and let it fail (because it couldn't find 
-lX11), then I rewrote the linking command, adding the 
correct library paths:

% cc -dynamiclib -o libTktable2.8.dylib tkTable.o \
tkTableWin.o tkTableTag.o tkTableEdit.o tkTableCell.o \
tkTableCellSort.o tkTableCmds.o tkTableUtil.o \
-L/Users/guest/X11ForMacOSXSource-wwdc/xc/lib/X11 \ 
-lX11 -L/Users/guest/tcltk/build/Tcl.framework \
-ltclstub8.4 -L/Users/guest/tcltk/build/Tk.framework \
-ltkstub8.4

Now libTktable2.8.dylib has been created successfully!

% mkdir /Users/guest/Tktable2.8
% cd /Users/guest/Tktable2.8
% cp /Users/guest/tcltk/Tktable2.8/libTktable2.8.dylib .
% cp /Library/Tcl/Tktable2.8/pkgIndex.tcl .
% cat pkgIndex.tcl
if {[catch {package require Tcl 8.2}]} return
package ifneeded Tktable 2.8 [list load [file join $dir 
libTktable2.8.dylib] Tktable]

When I get an administrator to log in with root access, the 
Tktable2.8 directory I created can be copied inside /sw/lib
but for now I can just use addTclPath("/Users/guest").

% R
> library(tcltk)
> addTclPath("/Users/guest")
> tclRequire("Tktable")
> tt <- tktoplevel()
> table1 <- tkwidget(tt,"table",bg="white")
> tkpack(table1)

Looks beautiful!

Regards,
James



More information about the R-SIG-GUI mailing list