• 首页 首页 icon
  • 工具库 工具库 icon
    • IP查询 IP查询 icon
  • 内容库 内容库 icon
    • 快讯库 快讯库 icon
    • 精品库 精品库 icon
    • 问答库 问答库 icon
  • 更多 更多 icon
    • 服务条款 服务条款 icon

在R包加载已编译的库

用户头像
it1352
帮助6

问题说明

我正在编写一个R包,其中需要将一个已编译的库文件qserver.dll包含在内,并在将该包加载到R到整个库(myPackage)中时dym.load.该qserver.dll由第三方供应商提供,所以我没有源代码.

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.

我在互联网上做了一些研究,但是信息很少.到目前为止,我发现我应该将此文件放在包文件夹的inst/子目录中.但是,在编写程序包时如何确定该文件的路径,以便可以编写类似

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.

正确答案

#1

可通过以下方式使用包的inst目录中的项目:

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

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

因此,假设您在包路径<pkg>/inst/lib/qserver.dll中包含了.dll,则可以

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>)

获取文件位置.

现在,当然,这是CRAN不能接受的,并且 CRAN储存库政策对此很清楚.因此,如果您确实需要qserver.dll,则要么需要找到源代码,要么考虑使用其他分发途径.

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.

这篇好文章是转载于:学新通技术网

  • 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
  • 本站站名: 学新通技术网
  • 本文地址: /reply/detail/tanhcajjkk
系列文章
更多 icon
同类精品
更多 icon
继续加载