Skip to content

R-beta: autoloading a required library

4 messages · Thomas Lumley, Albrecht Gebhardt

#
I wanted to use the dist() function from the mva library in my own
library, so I put require(mva) in my files. When my library loads, a
message about "Autoloading ... mva" appears. But when I call dist() now
within my functions the message

Error in .C("dist", as.double(x), nrow(x), ncol(x), double(len),
as.integer(method)) : C/Fortran function not in load table 

appears.

After dyn.load("..._path_to_/mva.so") it works.

Is there something wrong with the autoloading process or should 
statements like `if (!is.loaded("dist")) {dynload("mva.so")}` be added to 
the functions of the mva library? Or is this problem due to a wrong setup
in my R (0.50a4)? 


Albrecht

------------------------------------------------------------------
Albrecht Gebhardt           email: albrecht.gebhardt at uni-klu.ac.at
Institut fuer Mathematik    Tel. : (++43 463) 2700/837
Universitaet Klagenfurt     Fax  : (++43 463) 2700/834
Villacher Str. 161
A-9020 Klagenfurt, Austria
------------------------------------------------------------------





=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
#
On Mon, 17 Nov 1997, Albrecht Gebhardt wrote:

            
It's probably something wrong with the setup, but I don't know what. It
seems to work in my installation of R which is roughly 0.50a4.

Does it work if you use library(mva) instead?  This should be identical
except that it gives an error if "mva" doesn't exist, rather than a
warning.

gorn% R

R : Copyright 1997, Robert Gentleman and Ross Ihaka
Version 0.50 Alpha-4 (September 10, 1997)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type "license()" for details.

[Previously saved workspace restored]
[1] FALSE
Autoloading required library: mva 
[1] TRUE
[1] TRUE
and even if the require() is inside a function
[1] FALSE
Autoloading required library: mva 
[1] TRUE
[1] TRUE
-thomas

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=---
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=---
#
On Mon, 17 Nov 1997, Thomas Lumley wrote:

            
This works (but not within the workspace, where my problem occured).
the same behavior.


Now I tried loading my library within a new .RData workspace and
everything worked, but only the first time I use this workspace. 
The second time i get:

R : Copyright 1997, Robert Gentleman and Ross Ihaka
Version 0.50 Alpha-4 (September 10, 1997)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type "license()" for details.

[Previously saved workspace restored]
[1] FALSE
Autoloading required library: mva 
Autoloading required library: scompat
[1] FALSE
[1] ".Dyn.libs" ".Provided"

.Dyn.libs was created the first time I used this workspace and contains
(immediatly after the second start of R):
[1] "mva.so"

Maybe this is the reason why "mva.so" did not get loaded. Does R forget to
clear ".Dyn.libs" on shutdown?

Albrecht

------------------------------------------------------------------
Albrecht Gebhardt           email: albrecht.gebhardt at uni-klu.ac.at
Institut fuer Mathematik    Tel. : (++43 463) 2700/837
Universitaet Klagenfurt     Fax  : (++43 463) 2700/834
Villacher Str. 161
A-9020 Klagenfurt, Austria
------------------------------------------------------------------



=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=---
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=---
#
On Mon, 17 Nov 1997, Albrecht Gebhardt wrote:

            
Umm, yes. I'd forgotten that particular bug.  The quick fix is to add

if (exists(".Dyn.libs")) .Dyn.libs<-NULL

to the startup file

The solution was to put .Dyn.libs in the System environment instead of the
Global environment so it doesn't get saved.  I believe this is fixed in
the next version of R, due out roughly now.

	-thomas


=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=---
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=---