From ccberry at ucsd.edu  Tue Jul 22 06:13:06 2014
From: ccberry at ucsd.edu (Charles Berry)
Date: Tue, 22 Jul 2014 04:13:06 +0000
Subject: [Rd] create R package include Fortran source code.
References: <CAOrAJHdo7jcKfP1cauZYx+JmiSsZ1sU1YcDuFX4sJVF8nCqGVA@mail.gmail.com>
	<53CD42EE.3030204@gmail.com>
	<CAOrAJHeBs7vAU2Mr2U5xr9a1VgmKQ1V4k41TEZJq2+R=d5sNiw@mail.gmail.com>
Message-ID: <loom.20140722T055145-729@post.gmane.org>

yiqun yang <emiliawxr <at> gmail.com> writes:

> 
> Thank you for your reply.
> First I try "R CMD INSTALL barpkg", then it gives similiar things:
>
-------------------------------------------------------------

[deleted]

-------------------------------------------------------------
> 2) I don't know how to check the "compile" problem. I just try to
> "dyn.load" the shared object in /src-i386 and /src-x64 in the package, and
> they both work well.
> 
> I am guessing there is some error in the R language.
> ".First.lib"<-function(libname,pkgname){library.dynam("barpkg",pkgname,
> libname)}
> barfun<-function(n,x){
>    .Fortran("bar",as.integer(n),as.double(x))
> }
> package.skeleton(name="barpkg",list=c("barfun"))
> 
> I am not sure about this part. Can anyone give me some suggestion?



?.First.lib

refers to the base-defunct {base} help page which says:

[...]

# Defunct in 2.14.0
.First.lib(lib, pkg)

[...]
Details

Some of these have stubs which report that they are defunct, but most have
been removed completely (apart from being documented here).
[...]

====

So, don't use .First.lib.

Try a useDynLib directive in your NAMESPACE file.

You probably need to spend some time pondering 

  Writing R Extensions

especially section

1.5.4 useDynLib

HTH,

Chuck



[Rd] create R package include Fortran source code.
Charles Berry