From dankoc at gmail.com  Mon Nov 10 20:53:15 2008
From: dankoc at gmail.com (Charles Danko)
Date: Mon, 10 Nov 2008 14:53:15 -0500
Subject: [Rd] Dynamic linking to binary code from other packages??
In-Reply-To: <18691.32336.501605.415161@ron.nulle.part>
References: <8adccabf0810251305o3ad8483x5de5009605fbdbe1@mail.gmail.com>
	<18691.32336.501605.415161@ron.nulle.part>
Message-ID: <8adccabf0811101153w6a9e93bfvd7a24138f3c6b15b@mail.gmail.com>

Dear, R-devel,

Thanks very much for the response!

Here is what I am trying to do (also listed below in the previous messages):
"I am writing a package that needs some C++ functions from an external
SDK (Affymetrix fusion).  The same functions are already compiled into
another package (affxparser)."

I've looked through the "Writing R Extensions" manual, and can't find
this documented very clearly.  A previous question to the list gave me
the very kind response pasted below.  I've looked at the suggested
examples (lme4 using C functions from Matrix).

For lme4 to include Matrix C functions, I find it does this:
-- lme4 uses the line "LinkingTo" in the description file.
-- "Matrix.h" is an include in the C files.

Is this all that I need to do to my package?

But, of course, the header files still have to be included in the
Matrix install to make this work.  In the case of Matrix, it looks
like the header file is located at:
/usr/local/lib/R/site-library/Matrix/include/Matrix.h (under Ubuntu
8.10)

How does Matrix knows to export the Matrix.h header file here? What
else is the Matrix package doing to allow other packages to share its
C functions?

I apologize in advance if this is something obvious that I am missing!

Thanks, and warmest regards,

Charles

On Sat, Oct 25, 2008 at 3:15 PM, Dirk Eddelbuettel <edd at debian.org> wrote:
>
> On 25 October 2008 at 16:05, Charles Danko wrote:
> | Dear R-devel,
> |
> | I am writing a package that needs some C++ functions from an external
> | SDK (Affymetrix fusion).  The same functions are already compiled into
> | another package (affxparser).
> |
> | Can I dynamically link to the compiled code in affxparser, rather than
> | re-compiling these separately into my package?
>
> Yes.  Working examples are lme4 using Matrix.  This is documented in the 'R
> Extensions' manual.
>
> | Not a lot of experience on this subject!
>
> I don't think it is the easiest way around.  Maybe start by 'just'
> recompiling and relinking.
>
> Dirk
>
> --
> Three out of two people have difficulties with fractions.
>



[Rd] Dynamic linking to binary code from other packages??
Charles Danko