From bhh at xs4all.nl  Wed May 10 08:58:47 2017
From: bhh at xs4all.nl (Berend Hasselman)
Date: Wed, 10 May 2017 08:58:47 +0200
Subject: [Rd] registering Fortran routines in R packages
In-Reply-To: <696AFC2F-DD3D-4E5E-BC4E-12B87087CA6F@xs4all.nl>
References: <1CDAFD25-E227-42EA-A689-87B3036434AB@gmail.com>
 <93D3A75D-290F-49B3-9E37-FD88F78E2BEF@xs4all.nl>
 <1072BC5F-750D-4DF8-8B7B-7D8E665EDE00@gmail.com>
 <696AFC2F-DD3D-4E5E-BC4E-12B87087CA6F@xs4all.nl>
Message-ID: <3741DD7A-38B9-491F-B3D7-3C0E5BCB41AA@xs4all.nl>


> On 10 May 2017, at 08:48, Berend Hasselman <bhh at xs4all.nl> wrote:
> 
> Christophe, 
> 
>> On 10 May 2017, at 08:08, Christophe Dutang <dutangc at gmail.com> wrote:
>> 
>> Thanks for your email.
>> 
>> I try to change the name in lowercase but it conflicts with a C implementation also named halton. So I rename the C function halton2() and sobol2() while the Fortran function are HALTON() and SOBOL() (I also try lower case in the Fortran code). Unfortunately, it does not help since I get
>> 
>> init.c:97:25: error: use of undeclared identifier 'halton_'; did you mean 'halton2'?
>>  {"halton", (DL_FUNC) &F77_SUB(halton),  7},
>> 
>> My current solution is to comment FortEntries array and use R_useDynamicSymbols(dll, TRUE) for a dynamic search of Fortran routines.
> 
> Have a look at my package geigen and its init.c.
> Could it be that you are missing extern declarations for the Fortran routines?

I ran a development version of R some time ago with this 

tools:::package_native_routine_registration_skeleton("geigen",con="./geigen_report.txt")

to generate a skeleton init.c. I used that without modification.

Berend



[Rd] registering Fortran routines in R packages
Berend Hasselman