sen
January 13, 2021, 1:29pm
1
I tried to reinstall R, Rstudio, Rtools, but it still didn’t work. Thank you for your help
Error in compileCode(f, code, language = language, verbose = verbose) :
C:/rtools40/mingw64/bin/…/lib/gcc/x86_64-w64-mingw32/8.3.0/…/…/…/…/x86_64-w64-mingw32/bin/ld.exe: C:/Users/zhangsen/Documents/R/win-library/4.0/rstan/lib/x64/libStanServices.a(stan_fit.o):stan_fit.cpp:(.data$_ZZN5boost4math6detail9bessel_j0IeEET_S3_E2P1[_ZZN5boost4math6detail9bessel_j0IeEET_S3_E2P1]+0x0): multiple definition of boost::math::detail::bessel_j0<long double>(long double)::P1'; file3dfc2ff67f5.o:file3dfc2ff67f5.cpp:(.rdata$_ZZN5boost4math6detail9bessel_j0IeEET_S3_E2P1[_ZZN5boost4math6detail9bessel_j0IeEET_S3_E2P1]+0x0): first defined hereC:/rtools40/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Users/zhangsen/Documents/R/win-library/4.0/rstan/lib/x64/libStanServices.a(stan_fit.o):stan_fit.cpp:(.data$_ZZN5boost4math6detail9bessel_j0IeEET_S3_E2QS[_ZZN5boost4math6detail9bessel_j0IeEET_S3_E2QS]+0x0): multiple definition of
boost::math::detail::bessel_j0(long double)::QS’; file3dfc2ff67f5.o:file3dfc2ff67f
Error in sink(type = “output”) : 链结不对
Hi Sen, sorry about these troubles! There was a recent update to the BH
package that has broken rstan
a little.
Can you restart R, and then reinstall the packages from source:
install.packages(c("StanHeaders","rstan"),type="source")
1 Like
sen
January 14, 2021, 1:41pm
3
Thank you for your attention, your code works.
1 Like
hi there, i’ve tried all the tricks proposed in the forum, still got this error.
thx for helping
Can you post the full error message that you get?
hi, thx for the prompt reply.
after running {example(stan_model, run.dontrun = TRUE)}
i get a msg that is:
stn_md> stancode ← ‘data {real y_mean;} parameters {real y;} model {y ~ normal(y_mean,1);}’
stn_md> mod ← stan_model(model_code = stancode, verbose = TRUE)
TRANSLATING MODEL ‘73fc79f8b1915e8208c736914c86d1a1’ FROM Stan CODE TO C++ CODE NOW.
successful in parsing the Stan model ‘73fc79f8b1915e8208c736914c86d1a1’.
COMPILING THE C++ CODE FOR MODEL ‘73fc79f8b1915e8208c736914c86d1a1’ NOW.
OS: x86_64, mingw32; rstan: 2.21.2; Rcpp: 1.0.6; inline: 0.3.17
setting environment variables:
LOCAL_LIBS = “C:/R/library/rstan/lib/x64/libStanServices.a” -L"C:/R/library/StanHeaders/libs/x64" -lStanHeaders -L"C:/R/library/RcppParallel/lib/x64" -ltbb
PKG_CPPFLAGS = -I"C:/R/library/Rcpp/include/" -I"C:/R/library/RcppEigen/include/" -I"C:/R/library/RcppEigen/include/unsupported" -I"C:/R/library/BH/include" -I"C:/R/library/StanHeaders/include/src/" -I"C:/R/library/StanHeaders/include/" -I"C:/R/library/RcppParallel/include/" -I"C:/R/library/rstan/include" -DEIGEN_NO_DEBUG -DBOOST_DISABLE_ASSERTS -DBOOST_PENDING_INTEGER_LOG2_HPP -DSTAN_THREADS -DBOOST_NO_AUTO_PTR -include “C:/R/library/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp” -std=c++1y
after ther program source, i get the famous {Compilation ERROR, function(s)/method(s) not created!
Error in compileCode(f, code, language = language, verbose = verbose) :
In addition: Warning message:
In system(paste(CXX, ARGS), ignore.stdout = TRUE, ignore.stderr = TRUE) :
‘-E’ not found}
also, may be of interest:
devtools::session_info(“rstan”)
Session info --------------------------------------------------
setting value
version R version 4.0.4 (2021-02-15)
os Windows 10 x64
system x86_64, mingw32
ui RStudio
language (EN)
collate English_United States.1252
ctype English_United States.1252
tz Europe/Berlin
date 2021-04-27
Packages ------------------------------------------------------
! package * version date lib source
backports 1.2.1 2020-12-09 [1] CRAN (R 4.0.3)
BH 1.75.0-0 2021-01-11 [1] CRAN (R 4.0.3)
callr 3.7.0 2021-04-20 [1] CRAN (R 4.0.5)
checkmate 2.0.0 2020-02-06 [1] CRAN (R 4.0.5)
cli 2.4.0 2021-04-05 [1] CRAN (R 4.0.5)
colorspace 2.0-0 2020-11-11 [1] CRAN (R 4.0.5)
crayon 1.4.1 2021-02-08 [1] CRAN (R 4.0.5)
curl 4.3 2019-12-02 [1] CRAN (R 4.0.5)
desc 1.3.0 2021-03-05 [1] CRAN (R 4.0.5)
digest 0.6.27 2020-10-24 [1] CRAN (R 4.0.5)
ellipsis 0.3.1 2020-05-15 [1] CRAN (R 4.0.5)
fansi 0.4.2 2021-01-15 [1] CRAN (R 4.0.5)
farver 2.1.0 2021-02-28 [1] CRAN (R 4.0.5)
ggplot2 * 3.3.3 2020-12-30 [1] CRAN (R 4.0.5)
glue 1.4.2 2020-08-27 [1] CRAN (R 4.0.5)
gridExtra 2.3 2017-09-09 [1] CRAN (R 4.0.5)
gtable 0.3.0 2019-03-25 [1] CRAN (R 4.0.5)
inline 0.3.17 2020-12-01 [1] CRAN (R 4.0.5)
isoband 0.2.4 2021-03-03 [1] CRAN (R 4.0.5)
jsonlite 1.7.2 2020-12-09 [1] CRAN (R 4.0.5)
labeling 0.4.2 2020-10-20 [1] CRAN (R 4.0.3)
lattice 0.20-41 2020-04-02 [2] CRAN (R 4.0.4)
lifecycle 1.0.0 2021-02-15 [1] CRAN (R 4.0.5)
loo 2.4.1 2020-12-09 [1] CRAN (R 4.0.5)
magrittr 2.0.1 2020-11-17 [1] CRAN (R 4.0.5)
MASS 7.3-53 2020-09-09 [2] CRAN (R 4.0.4)
Matrix 1.3-2 2021-01-06 [2] CRAN (R 4.0.4)
matrixStats 0.58.0 2021-01-29 [1] CRAN (R 4.0.5)
mgcv 1.8-33 2020-08-27 [2] CRAN (R 4.0.4)
munsell 0.5.0 2018-06-12 [1] CRAN (R 4.0.5)
nlme 3.1-152 2021-02-04 [2] CRAN (R 4.0.4)
pillar 1.6.0 2021-04-13 [1] CRAN (R 4.0.5)
pkgbuild 1.2.0 2020-12-15 [1] CRAN (R 4.0.5)
pkgconfig 2.0.3 2019-09-22 [1] CRAN (R 4.0.5)
prettyunits 1.1.1 2020-01-24 [1] CRAN (R 4.0.5)
processx 3.5.1 2021-04-04 [1] CRAN (R 4.0.5)
ps 1.6.0 2021-02-28 [1] CRAN (R 4.0.5)
R6 2.5.0 2020-10-28 [1] CRAN (R 4.0.5)
RColorBrewer 1.1-2 2014-12-07 [1] CRAN (R 4.0.3)
Rcpp 1.0.6 2021-01-15 [1] CRAN (R 4.0.5)
RcppEigen 0.3.3.9.1 2020-12-17 [1] CRAN (R 4.0.5)
D RcppParallel 5.1.2 2021-04-15 [1] CRAN (R 4.0.5)
rlang 0.4.10 2020-12-30 [1] CRAN (R 4.0.5)
rprojroot 2.0.2 2020-11-15 [1] CRAN (R 4.0.5)
rstan * 2.21.2 2020-07-27 [1] CRAN (R 4.0.5)
scales 1.1.1 2020-05-11 [1] CRAN (R 4.0.5)
StanHeaders * 2.21.0-7 2020-12-17 [1] CRAN (R 4.0.5)
tibble 3.1.1 2021-04-18 [1] CRAN (R 4.0.5)
utf8 1.2.1 2021-03-12 [1] CRAN (R 4.0.5)
V8 3.4.1 2021-04-23 [1] CRAN (R 4.0.5)
vctrs 0.3.7 2021-03-29 [1] CRAN (R 4.0.5)
viridisLite 0.4.0 2021-04-13 [1] CRAN (R 4.0.5)
withr 2.4.2 2021-04-18 [1] CRAN (R 4.0.5)
[1] C:/R/library
[2] C:/R/R-4.0.4/library
D – DLL MD5 mismatch, broken installation.
I need a bit more of the error message, sorry. Can you copy as much of the output as possible above the : Compilation ERROR, function(s)/method(s) not created!
section?
If it’s easier, you can also copy it into a text file and upload that here instead
here it is:
stan_err_msg.txt (31.7 KB)
ok now i c that it fails at the Rccp level and the RccpParallel library has a brocken installation.
how to remedy that? i installed everything from source with dependencies = TRUE as instructed.
thx again for your assistance
Hmm that’s odd, it doesn’t actually have an error message in there. Let’s check that your c++ toolchain is working. Can you post the output from the following:
system("touch foo.cpp")
system("R CMD SHLIB foo.cpp")
Ok, that indicates some issues with your toolchain. To get a better idea of the issue, can you post the outputs from:
readLines("~/.Renviron")
readLines("~/.Rprofile")
readLines("~/.R/Makevars.win")
Sys.getenv("PATH")
It looks like your configuration is a little off. Can you go through the steps in the RStan Getting Started Guide to get everything setup?
can you please be precise? to which config is off?
i confirm i did follow those instructions many many many times
is this config then ok? because i still get the error
system(“touch foo.cpp”)
[1] 0
system(“R CMD SHLIB foo.cpp”)
[1] 1
readLines(“~/.Renviron”)
[1] “PATH="{RTOOLS40_HOME}\\usr\\bin; {PATH}"”
readLines(“~/.Rprofile”)
Error in file(con, “r”) : cannot open the connection
In addition: Warning message:
In file(con, “r”) :
cannot open file ‘C:/Users/naoua/OneDrive/Documents/.Rprofile’: No such file or directory
readLines(“~/.R/Makevars.win”)
[1] “”
[2] " CXX14 = g++ -std=c++1y "
[3] " CXX14FLAGS += -O3 -mmmx -msse -msse2 -msse3 -mssse3 -msse4.1 -msse4.2"
Sys.getenv(“PATH”)
[1] “C:\rtools40\usr\bin;C:\R\R-4.0.4\bin\x64;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\bin;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\libnvvp;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.0\bin;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.0\libnvvp;C:\Program Files\Microsoft MPI\Bin;C:\Windows\System32;C:\Windows;C:\Windows\System32\wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Windows\System32\OpenSSH;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\Program Files\Microsoft SQL Server\130\Tools\Binn;C:\Program Files (x86)\Wolfram Research\WolframScript;C:\Windows\System32;C:\Windows;C:\Windows\System32\wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Windows\System32\OpenSSH;C:\Program Files\Wolfram Research\WolframScript;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.0\bin\cuda;C:\Users\naoua\AppData\Roaming\Python\Python38\Scripts;C:\Program Files\NVIDIA Corporation\Nsight Compute 2019.4.0;C:\FFmpeg\bin;C:\rtools40;C:\rtools40\mingw64\bin;C:\Users\naoua\AppData\Local\Microsoft\WindowsApps;C:\Users\naoua\AppData\Local\Programs\MiKTeX 2.9\miktex\bin\x64;C:\Users\naoua\OneDrive\Documents\Python Scripts;C:\Users\naoua\AppData\Local\Programs\Microsoft VS Code\bin”
Yep, that looks better. Can you now restart R and try the rstan install from source again:
remove.packages(c("StanHeaders","rstan"))
install.packages(c("StanHeaders","rstan"),type="source")
smtg is odd here:
install.packages(c(“StanHeaders”,“rstan”),type=“source”)
Installing packages into ‘C:/R/library’
(as ‘lib’ is unspecified)
trying URL ‘https://cran.rstudio.com/src/contrib/StanHeaders_2.21.0-7.tar.gz ’
Content type ‘application/x-gzip’ length 1402572 bytes (1.3 MB)
downloaded 1.3 MB
trying URL ‘https://cran.rstudio.com/src/contrib/rstan_2.21.2.tar.gz ’
Content type ‘application/x-gzip’ length 1152008 bytes (1.1 MB)
downloaded 1.1 MB
Warning in install.packages :
installation of package ‘StanHeaders’ had non-zero exit status
Warning in install.packages :
installation of package ‘rstan’ had non-zero exit status
The downloaded source packages are in
‘C:\Users\naoua\AppData\Local\Temp\Rtmp63WjFW\downloaded_packages’
Restarting R session…
library(rstan)
Error in library(rstan) : there is no package called ‘rstan’
Are there any errors other than:
Warning in install.packages :
installation of package ‘StanHeaders’ had non-zero exit status
Warning in install.packages :
installation of package ‘rstan’ had non-zero exit status
Or is that all that is displayed?