Open y6t4 opened 6 years ago
I tried to go through the installation instructions again by following this page. I installed the macOS R toolchain using the macOS R toolchain installer.
I then configured clang++ in admin mode using the provided code:
dotR <- file.path(Sys.getenv("HOME"), ".R")
if (!file.exists(dotR)) dir.create(dotR)
MAKEVARS <- file.path(dotR, "Makevars")
if (!file.exists(MAKEVARS)) file.create(MAKEVARS)
cat(
"\nCXXFLAGS=-O3 -mtune=native -march=native -Wno-unused-variable -Wno-unused-function -Wno-macro-redefined -Wno-unknown-pragmas",
"\nCC=clang",
"CXX=clang++ -arch x86_64 -ftemplate-depth-256",
file = MAKEVARS,
sep = "\n",
append = TRUE
)
# print the contents to the console
cat(readLines(MAKEVARS), sep = "\n")
I then attempt to verify that the toolchain works by executing the code below in R and checking that it returns the value 10:
fx <- inline::cxxfunction( signature(x = "integer", y = "numeric" ) , '
return ScalarReal( INTEGER(x)[0] * REAL(y)[0] ) ;
' )
fx( 2L, 5 ) # should be 10
But I get the following error:
Error in compileCode(f, code, language = language, verbose = verbose) : Compilation ERROR, function(s)/method(s) not created! ld: library not found for -lintl clang: error: linker command failed with exit code 1 (use -v to see invocation) make: *** [filee7df6bc649.so] Error 1 In addition: Warning message: In system(cmd, intern = !verbose) : running command '/usr/local/Cellar/r/3.5.0/lib/R/bin/R CMD SHLIB filee7df6bc649.cpp 2> filee7df6bc649.cpp.err.txt' had status 1
I think this might be connected to my problem with the Stan model?
For the original question, you need to write / sqrt(n - 1.0)
with some compilers in order to force it to use the double-based implementation of the square root function.
@bgoodri I still get the same error.
Which error? You fixed the -lintl
thing, changed your Stan program to do
/ sqrt(n - 1.0);
, and it still gives you a compiler error about sqrt
being ambiguous?
On Fri, May 11, 2018 at 9:30 AM, y6t4 notifications@github.com wrote:
@bgoodri https://github.com/bgoodri I still get the same error.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/stan-dev/rstan/issues/524#issuecomment-388364069, or mute the thread https://github.com/notifications/unsubscribe-auth/ADOrqjVa9xXJCdtFUQp0y_p2lHAo1fA8ks5txZKHgaJpZM4T60On .
@bgoodri My apologies. I tried to respond to your comment on the Stan forum, but It said that my post was awaiting review.
How would I go about fixing the -lintl
thing?
The output from cat(readLines(MAKEVARS), sep = "\n")
is as follows:
> cat(readLines(MAKEVARS), sep = "\n")
# The following statements are required to use the clang4 binary
CC=/usr/local/clang4/bin/clang
CXX=/usr/local/clang4/bin/clang++
CXX1X=/usr/local/clang4/bin/clang++
CXX98=/usr/local/clang4/bin/clang++
CXX11=/usr/local/clang4/bin/clang++
CXX14=/usr/local/clang4/bin/clang++
CXX17=/usr/local/clang4/bin/clang++
LDFLAGS=-L/usr/local/clang4/lib
# End clang4 inclusion statements
# The following statement changes the Fortran linking path
FLIBS=-L/usr/local/gfortran/lib/gcc/x86_64-apple-darwin16/6.3.0
# End Fortran linking path statement
CXXFLAGS=-O3 -mtune=native -march=native -Wno-unused-variable -Wno-unused-function -Wno-macro-redefined -Wno-unknown-pragmas
CC=clang
CXX=clang++ -arch x86_64 -ftemplate-depth-256
CXXFLAGS=-O3 -mtune=native -march=native -Wno-unused-variable -Wno-unused-function -Wno-macro-redefined
CXXFLAGS+=-flto -Wno-unused-local-typedefs
CXXFLAGS += -Wno-ignored-attributes -Wno-deprecated-declarations
Start by deleting everything after
End Fortran linking path statement
On Fri, May 11, 2018 at 9:40 AM, y6t4 notifications@github.com wrote:
@bgoodri https://github.com/bgoodri My apologies. I tried to respond to your comment on the Stan forum, but It said that my post was awaiting review.
How would I go about fixing the -lintl thing?
The output from cat(readLines(MAKEVARS), sep = "\n") is as follows:
cat(readLines(MAKEVARS), sep = "\n")
The following statements are required to use the clang4 binary
CC=/usr/local/clang4/bin/clang CXX=/usr/local/clang4/bin/clang++ CXX1X=/usr/local/clang4/bin/clang++ CXX98=/usr/local/clang4/bin/clang++ CXX11=/usr/local/clang4/bin/clang++ CXX14=/usr/local/clang4/bin/clang++ CXX17=/usr/local/clang4/bin/clang++ LDFLAGS=-L/usr/local/clang4/lib End clang4 inclusion statements The following statement changes the Fortran linking path
FLIBS=-L/usr/local/gfortran/lib/gcc/x86_64-apple-darwin16/6.3.0 End Fortran linking path statement
CXXFLAGS=-O3 -mtune=native -march=native -Wno-unused-variable -Wno-unused-function -Wno-macro-redefined -Wno-unknown-pragmas
CC=clang CXX=clang++ -arch x86_64 -ftemplate-depth-256
CXXFLAGS=-O3 -mtune=native -march=native -Wno-unused-variable -Wno-unused-function -Wno-macro-redefined
CXXFLAGS+=-flto -Wno-unused-local-typedefs
CXXFLAGS += -Wno-ignored-attributes -Wno-deprecated-declarations
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/stan-dev/rstan/issues/524#issuecomment-388366593, or mute the thread https://github.com/notifications/unsubscribe-auth/ADOrqrYMNCNUvdYxRlEERf24yKgbCQ71ks5txZTBgaJpZM4T60On .
@bgoodri
I made the hidden files visible and tried to edit the Makevars
file. I get the following error when I try to save the changes:
You don’t own the file “Makevars” and don’t have permission to write to it.
This Stan program compiles and links for me in the latest RStan on Mac OS X.
@y6t4 Just do File -> Open in RStudio and browse to your home directory, then the .R subdirectory (which is possibly hidden), and then the Makevars file.
On Fri, May 11, 2018 at 10:01 AM, Bob Carpenter notifications@github.com wrote:
This Stan program compiles and links for me in the latest RStan on Mac OS X for me.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/stan-dev/rstan/issues/524#issuecomment-388372577, or mute the thread https://github.com/notifications/unsubscribe-auth/ADOrqq6hmRtFuYrpNG4e2Ybn28TkaEHtks5txZmzgaJpZM4T60On .
@bgoodri IT WORKED! Thank you so much for taking the time to help!!!!!! THANK YOU!
Summary:
I am trying to run my Stan code in an RStudio R Markdown file, but it will not compile and instead produces an error.
Description:
I am trying to run my Stan code in an RStudio R Markdown file, but it will not compile and instead produces an error. I have tried it on two different Mac machines, but the same error is produced.
My code is as follows:
Reproducible Steps:
I simply try to run the aforementioned code.
Current Output:
Expected Output:
I expect for the code to compile with the usual warnings.
RStan Version:
2.17.3
R Version:
"R version 3.5.0 (2018-04-23)"
Operating System:
macOS High Sierra 10.13.3
Session Info
R version 3.5.0 (2018-04-23) Platform: x86_64-apple-darwin17.5.0 (64-bit) Running under: macOS High Sierra 10.13.3
Matrix products: default BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib LAPACK: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libLAPACK.dylib
locale: removed
attached base packages: [1] stats graphics grDevices utils datasets methods base
other attached packages: [1] StanHeaders_2.17.2
loaded via a namespace (and not attached): [1] Rcpp_0.12.16 knitr_1.20 devtools_1.13.5 munsell_0.4.3
[5] colorspace_1.3-2 lattice_0.20-35 R6_2.2.2 rlang_0.2.0
[9] httr_1.3.1 plyr_1.8.4 tools_3.5.0 parallel_3.5.0
[13] grid_3.5.0 gtable_0.2.0 loo_2.0.0 git2r_0.21.0
[17] withr_2.1.2 matrixStats_0.53.1 lazyeval_0.2.1 digest_0.6.15
[21] tibble_1.4.2 rstan_2.17.3 Matrix_1.2-14 gridExtra_2.3
[25] ggplot2_2.2.1 curl_3.2 memoise_1.1.0 inline_0.3.14
[29] pillar_1.2.2 compiler_3.5.0 scales_0.5.0 stats4_3.5.0