I've been following the link (Guidelines for including TMB c++ code in an R package) to include a .cpp TMB model into my R package (fishmethods). I got it to work on Windows using a Makefile.win file with the code:
all: EP_likelihood.dll
# Comment here preserves the prior tab
EP_likelihood.dll: EP_likelihood.cpp
Rscript --vanilla -e "TMB::compile('EP_likelihood.cpp','-O0 -g',DLLFLAGS='')"
clean:
rm -rf *.dll
and, in the Description file, setting
LinkingTo: TMB
and adding "TMB" to the *Imports:" line. Also, I added to the "Namespace" file
importFrom("TMB","MakeADFun","sdreport")
and
useDynLib(EP_likelihood).
I am able to build and install the package on Windows. I want to make the .cpp model portable across platforms because the updated package will be put on CRAN. I've been reading the "Writing R Extensions" manual particularly under "Writing Portable Packages" but I don't understand fully what I have to do (I am not a professional programmer). Would anyone have any suggestions or have an example that I could examine?
Thanks in advance.