[Rcpp-devel] Rcpp shared libraries (?)
Serguei Sokol
serguei.sokol at gmail.com
Thu Jun 23 17:38:24 CEST 2022
Le 23/06/2022 à 17:12, THIOULOUSE JEAN a écrit :
> ...
>> I can make a PR if you wish.
>
> Yes, please do. Thanks a lot !
Done: https://github.com/sdray/ade4/pull/31
Serguei.
>>
>> Le 23/06/2022 à 16:10, Jean Thioulouse a écrit :
>>>> Le 23 juin 2022 à 16:04, Serguei Sokol <serguei.sokol at gmail.com> a écrit :
>>>>
>>>> Le 23/06/2022 à 15:47, Jean Thioulouse a écrit :
>>>>> Thank you Serguei, I tried this, but I still get the "undeclared identifier" error for these internal functions during package compilation:
>>>>> clang++ -arch arm64 -std=gnu++14 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I'/Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/library/Rcpp/include' -I'/Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/library/RcppArmadillo/include' -I/opt/R/arm64/include -fPIC -falign-functions=64 -Wall -g -O2 -c testertracenuCpp.cpp -o testertracenuCpp.o
>>>>> testertracenuCpp.cpp:112:9: error: use of undeclared identifier 'matcentrageCpp'
>>>>> i = matcentrageCpp (ti1p, pl, typ1);
>>>> I cannot find 'matcentrageCpp' in https://github.com/sdray/ade4/tree/ade4-Rcpp/. Do you have a current state example somewhere?
>>> Yes, I just pushed it in the ade4-Rcpp branch.
>>>>
>>>> Serguei.
>>>>
>>>>> ^
>>>>> Jean
>>>>>> Le 23 juin 2022 à 15:17, Serguei Sokol <serguei.sokol at gmail.com> a écrit :
>>>>>>
>>>>>> Le 23/06/2022 à 15:02, THIOULOUSE JEAN a écrit :
>>>>>>> Hi
>>>>>>> Sorry to bother you again with my C/C++ problems in the ade4 package (available on CRAN & GitHub).
>>>>>>> Thanks to your help, I have succeeded in converting several of the C functions to C++ using Rcpp. Now the package compiles without problem and all my C++ functions run fine in the dedicated GitHub branch of the package (ade4-Rcpp).
>>>>>>> The new problem I am facing now is that in ade4, I use a library of about 30 utilities functions collected in one file named adesub.c, with adesub.h headers file. From what I understand, during package compilation these functions are added to the ade4 shared library and they can be called by my other C functions without being declared in the init.c or NAMESPACE files, as they do not need to be known by R.
>>>>>>> I would like to know if it is possible to do the same thing in C++ with Rcpp.
>>>>>> If I understand correctly you goal, just don't put "// [[Rcpp::export]]" before your "internal" functions. They will be available to all C and C++ functions in src/ but not seen in R. You don't need extra "R CMD SHLIB" either.
>>>>>>
>>>>>> Best,
>>>>>> Serguei.
>>>>>>
>>>>>> I have found reading the documentation (Dirk's book and Rcpp vignettes) that I could use R CMD SHLIB to build a shared library and then dyn.load it in R. I have created a file named ade4lib.cpp containing the utilities functions in the src directory, and I can make the shared library (ade4lib.so) with RCMD SHLIB. But this does not solve my problem because, as I understand it, this makes the utilities library functions available to R (which is useless since they are not interfaced correctly to R but to C++), and not to the other C++ functions (which is what i need to do).
>>>>>>> Can anybody see where I am mistaken, and point me to the right direction to accomplish this ?
>>>>>>> Thank you,
>>>>>>> Jean
>>>>>>> —-
>>>>>>> Jean THIOULOUSE - https://lbbe-web.univ-lyon1.fr/en/annuaires-des-membres/thioulouse-jean
>>>>>>> https://orcid.org/0000-0001-7664-0598 (ORCID page)
>>>>>>> https://www.springer.com/fr/book/9781493988488 (ade4 Book)
>>>>>>> https://pbil.univ-lyon1.fr/JTHome/Biblio/ThioulouseEB2021.pdf (Evol. Biol. paper)
>>>>>>> _______________________________________________
>>>>>>> Rcpp-devel mailing list
>>>>>>> Rcpp-devel at lists.r-forge.r-project.org
>>>>>>> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
>>>>>>
>>>>
>>
>
More information about the Rcpp-devel
mailing list