My best guess is that the issue here is that 'gfortran' is being used for linking, e.g.
c:/Rtools/mingw_64/bin/gfortran -shared -s -Wl,--allow-multiple-definition -static-libgcc -o ForTest.dll tmp.def RcppExports.o VecSum_C.o VecSum_F.o -LC:/R/RLocalSoft/lib/x64 -LC:/R/RLocalSoft/lib -LC:/R/RCurrent/R-33~1.1PA/bin/x64 -lR You likely need to force the C++ compiler (g++) to be used for linking, although I'm not exactly ensure how to accomplish this. Hopefully, setting one of: SHLIB_LD = $(CXX) SHLIB_FCLD = $(CXX) DYLIB_LD = $(CXX) in your src/Makevars[.win] will be sufficient, but no guarantees... Kevin On Thu, Oct 6, 2016 at 9:37 AM, Dirk Eddelbuettel <e...@debian.org> wrote: > > 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 >
_______________________________________________ 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