質問

I am writing an R package where I need to include a compiled library file qserver.dll and dym.load it when the package is loaded in R throught library(myPackage). This qserver.dll is provided by a third party vendor so I don't have the source code.

I did some research on the internet but information is rare. What I have found so far is that I should put this file in the to inst/ subdirectory of my package folder. However, how I can determine the path to this file when writing the package so I can write something like

dyn.load("path/to/file/qserver.dll")

when writing the package. Thanks very much.

役に立ちましたか?

解決

Items in the inst directory of a package are made available through

system.file(..., package=<mypkg>)

so assuming you had that .dll in a package path <pkg>/inst/lib/qserver.dll, you can do

system.file("lib/qserver.dll", package=<mypkg>)

to get the file location.

Now, of course, this is not CRAN acceptable, and the CRAN Repository Policy is quite clear on this. So if you really need qserver.dll, either you need to find the source code, or consider a different route for distribution.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top