On 6 October 2016 at 12:19, Avraham Adler wrote: | Has anyone successfully created a package that uses Rcpp for C++ code | and which also has Fortran code? I'm experimenting with comparing | Fortran and C++ and if I could use Rcpp to handle the C++ portion, it | would reduce the steepness of the learning curve. | | However, I haven't had success. The following C++ and Fortran snippets | compile properly separately—the C++ as part of Rcpp and the Fortran | using R CMD SHLIB and dynload—and the R snippets call them properly, | but when I put both the .cpp and .f95 files in /src, I get the huge | error posted below the files. | | Am I missing something simple or will having C++ and Fortran code in | the same package prevent the use of Rcpp and require the old methods | of calling compiled code?
I was about to say 'sure, why not' when I remembered that Writiing R Extension has something to say about this in section 1.2.4: There is no guarantee that C++11 can be used in a package in combination with any other compiled language (even C), as the C++11 compiler may be incompatible with the native compilers for the platform. (There are known problems mixing C++11 with Fortran.) but then this warning is just about C++11 and Fortran. That said, your description above suggests that you are "simply" too optimistic about 'Rcpp Attributes' -- those do not aim to support all languages. They provide a (very powerful) convenience tool for Rcpp. And hence C++. If it works in a package, stick with a package. That gets you different compilation units, and hopefully sane linking. Dirk -- http://dirk.eddelbuettel.com | @eddelbuettel | e...@debian.org _______________________________________________ Rcpp-devel mailing list Rcpp-devel@lists.r-forge.r-project.org https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel