dyn.load crashes without any clue
I tried to use dyn.load
command for loading external dll libraries, but it close my R session after running the command every time. I'm using windows 10 and here is my R version:
version _
platform x86_64-w64-mingw32
arch x86_64
os mingw32
system x86_64, mingw32
status
major 3
minor 1.3
year 2015
month 03
day 09
svn rev 67962
language R
version.string R version 3.1.3 (2015-03-09) nickname Smooth Sidewalk
to test this, here is a simple code to lock screen using windows native dll:
dyn.load("C:WindowsSystem32user32.dll")
.Call("LockWorkStation")
It is locking my screen, but when I log in back, my R session is crashing.
dyn.load()
is not meant to be a way to load DLLs in general, but rather to load DLLs created by R's compiler tool chain as described in the Writing R Extensions manual.
DLLs can be used by linking to them in the Makevars.win file
PKG_LIBS = -L$(XXX_DIR)/lib -lxxx
as discussed at the end of section 1.2.1 Using Makevars, but this implies writing C wrappers around the DLL.
I'm not an expert on Windows and R, and it's unusual in R to rely on platform-specific libraries, so please take my comments with a grain of salt.
It seems it is going to work if I change .Call
to .C
. I conclude if you know how to run functions in DLL (using .Call
, .C
, .External
or maybe .Fortran
)you can use general DLLs in R.
下一篇: dyn.load崩溃没有任何线索