You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
library(TMB)
compile( "simple.cpp" ) # compile() is a function within the TMB library
Note: Using Makevars in /Users/cschwarz/.R/Makevars
clang++ -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I"/Users/cschwarz/Rlibs/TMB/include" -I"/Users/cschwarz/Rlibs/RcppEigen/include" -DTMB_SAFEBOUNDS -DLIB_UNLOAD=R_unload_simple -DTMB_LIB_INIT=R_init_simple -I/usr/local/include -fPIC -Wall -g -O2 -c simple.cpp -o simple.o
....
clang++ -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Library/Frameworks/R.framework/Resources/lib -L/usr/local/lib -o simple.so simple.o -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
[1] 0
i.e. a successful compilation
When running the R code on Windows it terminates with
C:/Rlibs/RCPPEI1/include/Eigen/src/Core/CoreEvaluators.h:960:8: warning: ignoring attributes on template argument 'Eigen::internal::packet_traits::type' {aka '__vector(2) double'} [-Wignored-attributes]
enum {
^
make: *** [C:/PROGRA1/R/R-41~1.0/etc/x64/Makeconf:245: simple.o] Error 1
Error in compile("simple.cpp") : Compilation failed
If you comment out the isfinite() statement it compiles fine.
TMB Version:
Mac: > packageVersion("TMB")
[1] ‘1.7.20’
Windows
packageVersion("TMB")
[1] ‘1.7.20’
R Version:
Mac: "R version 4.0.5 (2021-03-31)"
Windows: "R version 4.1.0 (2021-05-18)"
Operating System:
Mac: OS 11.3.1
Windows: Windows 8.1 Pro
Thanks
Carl Schwarz
The text was updated successfully, but these errors were encountered:
I'm afraid that you've lost me... I'm a Mac user and have seldom used C++
(except to write TMB functions).
I don't have a Makevars file (that I'm aware of), nor do I know how to set
C++ compiler options in this make file.
Can you point me in the right direction?
Can I specify this using the flags= parameter of the TMB::compile()
function?
For example, I ran
library(TMB)
compile( "simple.cpp", flags="-std=c++11") # compile() is a function
within the TMB library
and it looks like the std=c++11 in the output below appears to be set (i'm
assuming that if it appears twice in the call, it overrides the gnu++11
call??
"C:/rtools40/mingw64/bin/"g++ -std=gnu++11
-I"C:/PROGRA~1/R/R-41~1.0/include" -DNDEBUG -I"C:/Rlibs/TMB/include"
-I"C:/Rlibs/RCPPEI~1/include" -DTMB_SAFEBOUNDS
-DLIB_UNLOAD=R_unload_simple -DTMB_LIB_INIT=R_init_simple
-std=c++11 -c simple.cpp -o simple.o
In file included from C:/Rlibs/RCPPEI~1/include/Eigen/Core:397,
from C:/Rlibs/RCPPEI~1/include/Eigen/Dense:1,
from C:/Rlibs/TMB/include/TMB.hpp:53,
from simple.cpp:1:
but this leads to the same compilation error
....
double'} [-Wignored-attributes]
enum {
^
make: *** [C:/PROGRA~1/R/R-41~1.0/etc/x64/Makeconf:245: simple.o] Error 1
Error in compile("simple.cpp", flags = "-std=c++11") : Compilation failed
Thanks
Carl
Description:
Using the isfinite() function in TMB cases compiler error on Windows but not on Macintosh when using compile() in R
Reproducible Steps:
Here is my simple.cpp file>
#include <TMB.hpp>
template
Type objective_function::operator() ()
{
DATA_VECTOR( left ); // left and right values
PARAMETER( log_shape );
Type test;
Type test2;
test = pow(left(1)-log_shape,2);
test2 = isfinite(test);
ADREPORT (test);
REPORT(test);
return test2;
};
Here is my R code
library(TMB)
compile( "simple.cpp" ) # compile() is a function within the TMB library
dyn.load(dynlib("simple"))
simple.model <- MakeADFun(
data= list(left=10.1),
parameters=list(log_shape=3.1 ),
DLL="simple"
)
simple.model$fn(simple.model$par)
Current Output:
When running the R code on Macintosh
i.e. a successful compilation
When running the R code on Windows it terminates with
C:/Rlibs/RCPPEI
1/include/Eigen/src/Core/CoreEvaluators.h:960:8: warning: ignoring attributes on template argument 'Eigen::internal::packet_traits::type' {aka '__vector(2) double'} [-Wignored-attributes]1/R/R-41~1.0/etc/x64/Makeconf:245: simple.o] Error 1enum {
^
make: *** [C:/PROGRA
Error in compile("simple.cpp") : Compilation failed
If you comment out the isfinite() statement it compiles fine.
TMB Version:
Mac: > packageVersion("TMB")
[1] ‘1.7.20’
Windows
R Version:
Mac: "R version 4.0.5 (2021-03-31)"
Windows: "R version 4.1.0 (2021-05-18)"
Operating System:
Mac: OS 11.3.1
Windows: Windows 8.1 Pro
Thanks
Carl Schwarz
The text was updated successfully, but these errors were encountered: