[Rcpp-devel] <no subject>
Sean Robert McGuffee
sean.mcguffee at gmail.com
Wed Mar 23 23:59:58 CET 2011
Hi Dirk and/or List,
Thanks for the help!
First of all, let me apologize for somehow sending this to a Windows
related discussion--I'm actually on a mac. I'm completely oblivious to how
email-interfaced discussion groups work.
Regarding:
> Can you reduce the problem to something simpler?
Not easily. Basically, what I'm doing is trying to connect a functional
command-line-argument based C++ program/library to an R interface. My first
step was to simply make a C++ function that gets two strings from R to use
as file names. I got that to work just fine, so my next step was to try to
pass those to the library--which is where the problem arises. Dissecting out
part of the library is a mess because I have a tangled web of
cross-functionality in that library.
Somewhat related to that:
Honestly, I'm very new to R and have an extremely difficult time
understanding most of it's documentation. I think a lot of times the people
who write it are close to it and know what they mean, but I tend not to. The
skeleton thing didn't come with libraries, so I think that is the key to my
problem. I have to link to my library, and so far I'm attempting that by
literally copying all the source files into the src directory. I'd much
rather just link to the already compiled and functional library with small
functions but haven't found any way to do that. If you could help me with
that, I would very much appreciate it. I need to link to my library, I
assume there might be some need for my headers, and also to the headers and
libraries referenced by it. If you could give me a generic mechanism for
doing that, I'd very much appreciate it.
Regarding:
> We would need to see what you do in file R/zzz.R and the .onLoad() function
> (assuming you use a NAMESPACE). Else we'd need the equivalent .First.lib()
> function.
starting by going to my package directory (which worked prior to attempting
to attach a library)
cd R_PACKAGES/alignR/
cat NAMESPACE
useDynLib(alignR)
export(colorSpaceToSequenceSpace)
ls R/
README colorSpaceToSequenceSpace.R
cat R/colorSpaceToSequenceSpace.R
colorSpaceToSequenceSpace <- function(colorSpace,sequenceSpace){
params <- list(colorSpaceFile=colorSpace,sequenceSpaceFile=sequenceSpace)
.Call( "colorSpaceToSequenceSpace",params, PACKAGE = "alignR" )
}
That's all I have that is unique from the skeleton in that directory.
Regarding other configuration:
cd /Library/Frameworks/R.framework/Resources/etc/x86_64
grep srm Makeconf
SHLIB_LIBADD =
/WHITEHOUSE_LAB/WHITEHOUSE_LAB_PROGRAMS/LIBSRM/LIB/libsrm.SeanBenchGcc.so
I started off by using a static library
/WHITEHOUSE_LAB/WHITEHOUSE_LAB_PROGRAMS/LIBSRM/LIB/libsrm.SeanBenchGcc.a
which I would prefer to use because making the dynamic one was a pain and
I'm so unfamiliar with that process I don't know if I'm doing it correctly,
but neither way works so far. I haven't tried including other libraries such
as libpng14 and shark and some other curve fitting libraries, but it seemed
to me that if I'm compiling and linking okay and they aren't being called
*YET*, that should be okay. I would like to know how to link to those in R
eventually though. Also, I might be wrong about them not mattering if they
don't get called and wonder if that could be a source of my problem. What I
do to use my library from the command line is compile interface code with
headers from my libaries and libaries it references and statically link to
it and other libraries. I get the feeling that there must be a way to do
this in an R interface, I'm just not clear as to how.
I hope this paints a clearer picture of what my problem is.
Thanks again for any help,
Sean
On 3/23/11 7:49 AM, "Dirk Eddelbuettel" <edd at debian.org> wrote:
>
> Hi Sean,
>
> On 23 March 2011 at 00:20, Sean Robert McGuffee wrote:
> | Hi,
> | I¹m new to using C++ inside of R. I got a test program to work, so
> | it¹s time for me to attach some function to it. I seem to be having
> | some issues though. I wonder if anyone out there can help me
> | understand the results I am getting. I¹ve got to a point where it
> | seems to me that everything is installing but then afterwards it
>
> Everything is _compiling_ and _linking_ which is good but...
>
> | segmentation faults. In particular the following are the parts where
> | the problem comes up:
> | ** testing if installed package can be loaded
> | *** caught segfault ***
> | address 0x20, cause 'memory not mapped'
>
> ...when the build process tries to load the package you are building you get
> a run-time error as is clearly shown by the traceback. Some initalization
> goes nelly-up, could be your C++ code or your other library
> (libsrm.SeanBenchGcc ?).
>
> Can you reducde the problem to something simpler?
>
> | If anyone has any suggestions, please let me know. The full version of
> | the installation command and results is below:
>
> We would need to see what you do in file R/zzz.R and the .onLoad() function
> (assuming you use a NAMESPACE). Else we'd need the equivalent .First.lib()
> function.
>
> Dirk
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20110323/e85bf554/attachment.htm>
More information about the Rcpp-devel
mailing list