From ncrook@ton@|@ @end|ng |rom gm@||@com  Thu Dec 12 18:41:16 2019
From: ncrook@ton@|@ @end|ng |rom gm@||@com (Nicholas Crookston)
Date: Thu, 12 Dec 2019 09:41:16 -0800
Subject: [Rd] Dynamic load library problem using R 4.0.0
In-Reply-To: <CAAk+MXz+XSXaFcogbRPBPPyWzUzM8-Mg=1DfU6WOUXuDrEfK0A@mail.gmail.com>
References: <CAAk+MXz+XSXaFcogbRPBPPyWzUzM8-Mg=1DfU6WOUXuDrEfK0A@mail.gmail.com>
Message-ID: <CAAk+MXxic6pJrf1tVyUpd12Hr_4k+phSvGDAyajEC2Lk=KnEBg@mail.gmail.com>

Case closed.  My error was that I had not included an "export" option to
the linker and the symbols were not being exported (I was out of practice
building Window's dlls). The nm command output didn't help me. Thanks to
Tomas Kalibera and Jeroen Ooms for some helpful correspondence.


On Tue, Dec 3, 2019 at 1:41 PM Nicholas Crookston <ncrookston.fs at gmail.com>
wrote:

> I'm having problems getting code that runs under 3.6.1 on MacOSX (and
> Ubuntu)
> to run the R version 4.0.0 on Windows. I have not tested R 4.0.0 on mac
> (yet).
>
> Key question: Has anything changed in R 4.0.0/Windows regarding how
> dynamically loaded
> libraries are accessed?  Can someone please point me in the right
> direction?
>
> WORKS On MacOSX Under:
> R version 3.6.1 (2019-07-05) -- "Action of the Toes"
> after dynamically loading ../../bin/qFVSie.so:
>
> > getLoadedDLLs()$qFVSie
> DLL name: qFVSie
> Filename:
>
> /Users/ncrookston/open-fvs/branches/NickDev/tests/APIviaR/../../bin/qFVSie.so
> Dynamic lookup: TRUE
>
> # expected output is correct:
> > i=1
> > .C("CfvsSpeciesCode",fvs_code="",fia_code="",plant_code="",
> indx=as.integer(i))
> $fvs_code
> [1] "WP"
> $fia_code
> [1] "119"
> $plant_code
> [1] "PIMO3"
> $indx
> [1] 1
>
> ----- from the nm command:
> $ nm ../../bin/qFVSie.so | grep -i cfvsspeciescode
> 00000000000a7980 T _CfvsSpeciesCode
>
> ------------------------------------
>
> Fails On Win10 Under:
> R version 4.0.0 Under development (Rtools 4.0) (2019-11-23 r77455) --
> "Blame Jeroen"
> NOTE: The .dll is built using the most recent Rtools as advised by Jeroen.
>
> > getLoadedDLLs()$qFVSie
> DLL name: qFVSie
> Filename:
>
> C:/Users/nickc/open-fvs/branches/NickDev/tests/APIviaR/../../bin/qFVSie.dll
> Dynamic lookup: TRUE
>
> > i=1
> > .C("CfvsSpeciesCode",fvs_code="",fia_code="",plant_code="",
> indx=as.integer(i))
> Error in .C("CfvsSpeciesCode", fvs_code = "", fia_code = "", plant_code =
> "",  :
>   C symbol name "CfvsSpeciesCode" not in load table
>
> ----- from the nm command on Win10:
> nm ../../bin/qFVSie.dll | grep -i cfvsspeciescode
> 00000000707a21f0 T CfvsSpeciesCode
>
> -----------------------------------
>
> If advised to do so, I'll create a simple and fully reproducible example,
> but perhaps
> I missing something simple (like compiler switch needed to create my .dll
> that has not
> been necessary until now).
>
> Thanks, Nick
>
> --
> Nicholas L. Crookston
> Forestry Research Consultant
> Moscow Idaho USA
>


-- 
Nicholas L. Crookston
Forestry Research Consultant
Moscow Idaho USA

	[[alternative HTML version deleted]]



[Rd] Dynamic load library problem using R 4.0.0
Nicholas Crookston