[R-SIG-Mac] tkrplot failure to load

Diego Diez diez at kuicr.kyoto-u.ac.jp
Tue Aug 15 08:21:31 CEST 2006


Hello, Im having problems loading the tkrplot package in MacOSX and  
found a workaround, though I dont know how to make a "generic" patch  
for all platforms. Here is some info:

 > library(tkrplot)
Loading required package: tcltk
Loading Tcl/Tk interface ... done
Error in structure(.External("dotTcl", ..., PACKAGE = "tcltk"), class  
= "tclObj") :
	[tcl] image not found
NSCreateObjectFileImageFromFile() error: not a Mach-O MH_BUNDLE file.
Error in library(tkrplot) : .First.lib failed for 'tkrplot'
 > sessionInfo()
Version 2.3.1 (2006-06-01)
powerpc-apple-darwin8.6.0

attached base packages:
[1] "tcltk"     "methods"   "stats"     "graphics"  "grDevices"  
"utils"     "datasets"
[8] "base"


The tkrplot packages is installed in the following directory:

/Library/Frameworks/R.framework/Resources/library/tkrplot

with the relevant files being:

/Library/Frameworks/R.framework/Resources/library/tkrplot/R/tkrplot
/Library/Frameworks/R.framework/Resources/library/tkrplot/libs/ppc/ 
tkrplot.so

in tkrplot file:

.First.lib <- function(lib, pkg) {
     if (! .Tkrplot.loaded) {
         chname<-"tkrplot"
         file.ext <- .Platform$dynlib.ext
         path <- file.path("libs", paste(chname, file.ext, sep = ""))
         file <- system.file(path, package = pkg, lib.loc = lib)[1]
         .Tcl(paste("load", file, "Rplot"))
         .Tkrplot.loaded <<- TRUE
     }
}

it fails because the "file" variable returns "". This is because  
"path" variable is "../libs/tkrplot.so" and it should be "../libs/ppc/ 
tkrplot.so". If I make this change:

chname<-"tkrplot"
-----------------
chname<-"ppc/tkrplot"

then it works fine:

 > library(tkrplot)
Loading required package: tcltk
Loading Tcl/Tk interface ... done


I don't know if the file tkrplot.so should be under "libs" directory  
instead of "ppc/libs" or if the call to .First.lib should take into  
account the architecture.

By the way, this "patch" works.

Best.

Diego.



More information about the R-SIG-Mac mailing list