Working in Windows, I've created an r package that links to a c++ dll as a shared library. This works fine and installs without problems on Windows. When I switch to linux, however, the so is not found.
Am I right in thinking that the only file in the src directory should be the .cpp file?
Do I actually need to run the SHLIB command in that directory before I create the package?
In the NAMESPACE I use:
useDynLib(myc.cpp,my.c.function)
and in the function call:
my.r.f <- .Call(my.c.function, a, b)
On windows running R CMD check works fine. Could it be my linux R configuration that is to blame? It seems to install 3rd party packages fine.
I'm stumped!
Once RTools is set up, you can go about creating the package. In RStudio, select File > New Project > New Directory > R Package. In the dialog box that pops up, give the package a name and enter the directory in which you want the package to reside.
Before getting started, you will need to load two packages: You now want to open File in RStudio and select New Project, which will put you at this point: Select a new directory as desired, and specify R Package, as shown in the following screenshot:
C# Corner. Creating and Using DLL (Class Library) in C#. Introduction. A Dynamic Link library (DLL) is a library that contains functions and codes that can be used by more than one program at a time. Once we have created a DLL file, we can use it in many applications. The only thing we need to do is to add the reference/import the DLL File.
Note that the description of the package still says “What the Package Does (Title Case)”. We’ll fix that in a bit. Next, look at the “Files” tab. You’ll see a bunch of files and directories that RStudio created for your project. The script files will be in the “R” directory and the help files will be in the “man” directory.
There are several hundred packages on CRAN which do successfully what you attempt to do -- build a package with to-be-compiled sources on any of the supported platforms.
A strategy I quite like is to take one or more existing package and look exactly how they are set up. You can then copy the working recipe depending on how it corresponds to your setup (with or without NAMESPACE, with or without external library like libxml etc pp_)
I think you should just use useDynLib(myc)
... The symbol lookup is done internally.
EDIT: The other thing is the name of this object file -- I think the standard makefile just names it with package name, so it should be rather useDynLib(<package name>)
. At least it always works for me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With