Skip to content
Prev 39923 / 63424 Next

[Rcpp-devel] Question on 5.6 Interfacing C++ code

Hi All,

Just to follow up, I finally figured out a way to make a simple test project
I'm working on to compile and install and have access the code inside of R.
It turns out it was related to this "foo" name. I had to make the name of my
dynamic library output have the same name as the "foo" from the DESCRIPTION
file (and useDynLib(foo) ). I had made changes from a sample Rcpp program
where I liked the way args were passed. However, I didn't keep the name of
my dynamic library the same as the name of my directory and the name of my
functions and the name of my code files and the name of my project, and it
seems to me that it matters in about three places that need to match.
Eventually, after weeks of guessing incorrectly that I was doing something
else wrong altogether, I tried renaming the files and got one permutation to
work. After fiddling around with it to get to the bottom of what was going
on, I got one of my old original directories out and simply changed the
dynamic library name between the src/ and the .so part to match with the
name in the DESCRIPTION and the name inside the useDynLib() inside the
NAMESPACE file. Was this obvious to everyone else from reading the manual?
There were so many things I didn't understand that I missed that part.
Anyway, I've learned something about autoconf out of the whole ordeal, so
sometimes it pays off for me to be so silly. Anyway, I'd just like to
confirm that this is correct:

If I want to name a package "MY_PACKAGE_NAME"
then I have to do three things with this name to get Rcpp and/or my package
calling c++ to install and run correctly. I'll call my package directory TOP
1) put the line "Package: MY_PACKAGE_NAME" inside of TOP/DESCRIPTION
2) put the line "useDynLib(MY_PACKAGE_NAME)" inside of TOP/NAMESPACE
3) make sure the final dynamic library is named TOP/src/MY_PACKAGE_NAME.so
Do the experts agree that this is correct and necessary?

I happen to have named TOP to be MY_PACKAGE_NAME too, is that important too?
I also happen to be naming my function MY_PACKAGE_NAME too, is that
important? If I want to add more functions, I assume I can do that as long
as I link them into the TOP/src/MY_PACKAGE_NAME.so file. Is that correct?

Thanks in advance, 

Sean
On 4/21/11 10:57 AM, "Simon Urbanek" <simon.urbanek at r-project.org> wrote:

            
http://cran.r-project.org/doc/manuals/R-exts.html#Linking-GUIs-and-other-fr>>>>
o