Hi everybody, I'm working on Mac OS X and R-2.1.0 (by the way, sorry for the multiple emails last time, had a technical problem, and thanks for the constructive comments.) I have a .R function which calls a .C function. The R function's name is K_MEANSR.R and the other is K_MEANSC.C. I compile it with 'R CMD SHLIB K_MEANSC.C' in the terminal. I get both .so and .o files. I use the function > dyn.load ('K_MEANSC.so') with no error. We can, I believe, see here that it is loaded: > getLoadedDLLs() Filename base base grDevices /Library/Frameworks/R.framework/Resources/library/grDevices/libs/grDevices.so stats /Library/Frameworks/R.framework/Resources/library/stats/libs/stats.so methods /Library/Frameworks/R.framework/Resources/library/methods/libs/methods.so K_MEANSC /Users/admin/Desktop/Marie/Marie_labo_29_juin/K-means_versions/MAC/K_MEANSC.so R_X11 /Library/Frameworks/R.framework/Resources/modules/R_X11.so Dynamic.Lookup base FALSE grDevices FALSE stats FALSE methods FALSE K_MEANSC TRUE R_X11 TRUE I then source the R code: > source(file.choose()) Construct a matrix that I will use for the analysis: > tab<-c(1,1,3,4,6,6,3,5,7,67,5,6,65,3,5,1,5,42,3,567,6,4,7,7) > tab<-matrix(tab,6,4) And try to use the function: > K_MEANSR(tab,centers=c(2,4)) [1] "AA" [1] "AAA" [1] "A" [1] "B" Error in .C("K_MEANSC", xrows = as.integer(xrows), xcols = as.integer(xcols), : "C" function name not in load table Everything that is printed on the screen is correct, but why does it says that 'K_MEANSC' function is not in load table??? It then just stops at that stage of the .R function. Thank you all for your time, Marie-Hélène =========================================================Marie-Hélène Ouellette UNIVERSITE DE MONTRÉAL Département de sciences biologiques Tél. (514) 343-6111 poste 1233 ======================================================== [[alternative HTML version deleted]]
On Wed, 6 Jul 2005, [iso-8859-1] Marie-Hélène Ouellette wrote:> And try to use the function: > > K_MEANSR(tab,centers=c(2,4)) > [1] "AA" > [1] "AAA" > [1] "A" > [1] "B" > Error in .C("K_MEANSC", xrows = as.integer(xrows), xcols > as.integer(xcols), : > "C" function name not in load table >Hmm. Strange. R doesn't think your C function is called K_MEANSC (I assume that K_MEANSC *is* actually the name of your C function.) In a Terminal window you can use nm K_MEANSC.so to see all the names of externally visible objects in your DLL. This would narrow down whether the change of names is happening in R or in compilation. -thomas
At 19:46 2005-07-06, you wrote:>Marie-H?l?ne Ouellette wrote: >>Hi everybody, >>I'm working on Mac OS X and R-2.1.0 (by the way, sorry for the multiple >>emails last time, had a technical problem, and thanks for the >>constructive comments.) >>I have a .R function which calls a .C function. The R function's name is >>K_MEANSR.R and the other is K_MEANSC.C. >>I compile it with 'R CMD SHLIB K_MEANSC.C' in the terminal. I get both >>.so and .o files. >>I use the function >> > dyn.load ('K_MEANSC.so') >>with no error. We can, I believe, see here that it is loaded: >> >> > getLoadedDLLs() >> >>Filename >>base base >>grDevices >>/Library/Frameworks/R.framework/Resources/library/grDevices/libs/grDevices.so >>stats /Library/Frameworks/R.framework/Resources/library/stats/libs/stats.so >>methods >>/Library/Frameworks/R.framework/Resources/library/methods/libs/methods.so >>K_MEANSC >>/Users/admin/Desktop/Marie/Marie_labo_29_juin/K-means_versions/MAC/K_MEANSC.so >>R_X11 /Library/Frameworks/R.framework/Resources/modules/R_X11.so >> Dynamic.Lookup >>base FALSE >>grDevices FALSE >>stats FALSE >>methods FALSE >>K_MEANSC TRUE >>R_X11 TRUE >> >>I then source the R code: >> > source(file.choose()) >>Construct a matrix that I will use for the analysis: >> > tab<-c(1,1,3,4,6,6,3,5,7,67,5,6,65,3,5,1,5,42,3,567,6,4,7,7) >> > tab<-matrix(tab,6,4) >>And try to use the function: >> > K_MEANSR(tab,centers=c(2,4)) >>[1] "AA" >>[1] "AAA" >>[1] "A" >>[1] "B" >>Error in .C("K_MEANSC", xrows = as.integer(xrows), xcols = >>as.integer(xcols), : >> "C" function name not in load table >>Everything that is printed on the screen is correct, but why does it says >>that 'K_MEANSC' function is not in load table??? It then just stops at >>that stage of the .R function. > >What does your declaration of the function look like in the K_MEANSC.C >file? R needs to know the name of the exported function, not the name of >the .so file. > >Duncan MurdochIt's in the form: K_MEANSC<- function(arguments...) { } So the name of my .C function is also K_MEANSC... Marie-H?l?ne =========================================================Marie-H?l?ne Ouellette UNIVERSITE DE MONTR?AL D?partement de sciences biologiques T?l. (514) 343-6111 poste 1233
Apparently Analagous Threads
- minimisation problem, two setups (nonlinear with equality constraints/linear programming with mixed constraints)
- another automation question
- problems installing R from source: R-2.1.1 Windows XP
- beginners k means clustering question
- to delete lines by means of a vector