Is it possible to set Windows' search path from within R, or to tell Windows how to find a DLL in some other way from R? Specifically, if a package DLL depends on another DLL the normal requirement is that the second DLL be in the search path so Windows can find it (there are other tricks, but they apply at the Windows level, not at the R level). Thanks, Dominick [[alternative HTML version deleted]]
On 09/07/2010 2:38 PM, Dominick Samperi wrote:> Is it possible to set Windows' search path from within R, or > to tell Windows how to find a DLL in some other way from > R? Specifically, if a package DLL depends on another DLL > the normal requirement is that the second DLL be in the > search path so Windows can find it (there are other tricks, > but they apply at the Windows level, not at the R level). >I haven't tried this, but can't you use Sys.setenv() to change the PATH to what you want? Presumably you'll want to change it back afterwards. Duncan Murdoch
On 07/09/2010 11:38 AM, Dominick Samperi wrote:> Is it possible to set Windows' search path from within R, or > to tell Windows how to find a DLL in some other way from > R? Specifically, if a package DLL depends on another DLL > the normal requirement is that the second DLL be in the > search path so Windows can find it (there are other tricks, > but they apply at the Windows level, not at the R level).This thread https://stat.ethz.ch/pipermail/r-devel/2008-January/047961.html might be relevant, especially the DLLpath argument to dyn.load. Martin> > Thanks, > Dominick > > [[alternative HTML version deleted]] > > ______________________________________________ > R-devel at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel-- Martin Morgan Computational Biology / Fred Hutchinson Cancer Research Center 1100 Fairview Ave. N. PO Box 19024 Seattle, WA 98109 Location: Arnold Building M1 B861 Phone: (206) 667-2793
Dominick, Dominick Samperi wrote:> On Fri, Jul 9, 2010 at 3:48 PM, Duncan Murdoch > <murdoch.duncan at gmail.com>wrote: > >> On 09/07/2010 2:38 PM, Dominick Samperi wrote: >> >>> Is it possible to set Windows' search path from within R, or to tell >>> Windows how to find a DLL in some other way from R? Specifically, if >>> a package DLL depends on another DLL the normal requirement is that >>> the second DLL be in the search path so Windows can find it (there >>> are other tricks, but they apply at the Windows level, not at the R >>> level). >>> >>> >> >> >> I haven't tried this, but can't you use Sys.setenv() to change the >> PATH to what you want? Presumably you'll want to change it back >> afterwards. >> > > Thanks, good suggestion, but it does not seem to work. If PATH is > updated in this way the change is local to the current process, not to > the top-level Windows process, so a subsequent > dyn.load('foo.dll') will fail if foo.dll depends on bar.dll, unless > bar.dll is placed in the search path for the top-level shell. Seems > like this needs to be done as part of system startup outside of R. > > On the other hand, if foo.dll is the package library for package foo, > and if foo depends on package bar, then there is no need to place > bar.dll in the top-level search path. R takes care of this (more > typical) situation.there is another Windows "feature" which will do the trick for you without modifying the search path. Windows normally only loads DLLs once, so this means if you first load the dependent DLL (manually, e.g. using dyn.load()) then the already loaded DLL will be used instead of trying to load one from path. E.g. in your example: dyn.load("mypath/bar.dll") dyn.load("foo.dll") will work, as bar.dll (a dependency of foo.dll) is already loaded. Thomas