Compalitation errors when running stanc and stan_model on Windows
Open
Nobody has claimed this yet.
- Dominant language
- R
- Stars
- 1.1k
- Forks
- 266
- Avg merge
- 2h 56m
- Merged PRs (30d)
- 1
Description
Summary:
Can't build stan model using stanc and stan_model
Reproducible Steps:
library(rstan)
fixed_effect <-
"data {
int<lower=1> N; //number of data points
int<lower=1> K;
real intensity[N]; //protein or peptide intensity
matrix[N,K] dilution; //design matrix (predictor)
}
parameters {
vector[K] beta; //intercept and slope
real<lower=0> sigma_e; //error sd
}
model {
intensity ~ normal(dilution * beta , sigma_e);
}
"
rt <- stanc(model_code = fixed_effect)
sm <- stan_model(stanc_ret = rt, verbose = FALSE)
Current Output:
> sm <- stan_model(stanc_ret = rt, verbose = FALSE)
make cmd is
make -f "C:/PROGRA~1/R/R-40~1.3/etc/x64/Makeconf" -f "C:/PROGRA~1/R/R-40~1.3/share/make/winshlib.mk" CXX='$(CXX14) $(CXX14STD)' CXXFLAGS='$(CXX14FLAGS)' CXXPICFLAGS='$(CXX14PICFLAGS)' SHLIB_LDFLAGS='$(SHLIB_CXX14LDFLAGS)' SHLIB_LD='$(SHLIB_CXX14LD)' SHLIB="file9746d052a95.dll" WIN=64 TCLBIN=64 OBJECTS="file9746d052a95.o"
make would use
if test "zfile9746d052a95.o" != "z"; then \
if test -e "file9746d052a95-win.def"; then \
echo "C:/rtools40/mingw64/bin/"g++ -shared -s -static-libgcc -o file9746d052a95.dll file9746d052a95-win.def file9746d052a95.o "C:/Users/wewol/OneDrive/Documents/R/win-library/4.0/rstan/lib/x64/libStanServices.a" -L"C:/Users/wewol/OneDrive/Documents/R/win-library/4.0/StanHeaders/libs/x64" -lStanHeaders -L"C:/Users/wewol/OneDrive/Documents/R/win-library/4.0/RcppParallel/lib/x64" -ltbb -L"C:/PROGRA~1/R/R-40~1.3/bin/x64" -lR ; \
"C:/rtools40/mingw64/bin/"g++ -shared -s -static-libgcc -o file9746d052a95.dll file9746d052a95-win.def file9746d052a95.o "C:/Users/wewol/OneDrive/Documents/R/win-library/4.0/rstan/lib/x64/libStanServices.a" -L"C:/Users/wewol/OneDrive/Documents/R/win-library/4.0/StanHeaders/libs/x64" -lStanHeaders -L"C:/Users/wewol/OneDrive/Documents/R/win-library/4.0/RcppParallel/lib/x64" -ltbb -L"C:/PROGRA~1/R/R-40~1.3/bin/x64" -lR ; \
else \
echo EXPORTS > tmp.def; \
"C:/rtools40/mingw64/bin/"nm file9746d052a95.o | sed -n 's/^.* [BCDRT] / /p' | sed -e '/[.]refptr[.]/d' -e '/[.]weak[.]/d' | sed 's/[^ ][^ ]*/"&"/g' >> tmp.def; \
echo "C:/rtools40/mingw64/bin/"g++ -shared -s -static-libgcc -o file9746d052a95.dll tmp.def file9746d052a95.o "C:/Users/wewol/OneDrive/Documents/R/win-library/4.0/rstan/lib/x64/libStanServices.a" -L"C:/Users/wewol/OneDrive/Documents/R/win-library/4.0/StanHeaders/libs/x64" -lStanHeaders -L"C:/Users/wewol/OneDrive/Documents/R/win-library/4.0/RcppParallel/lib/x64" -ltbb -L"C:/PROGRA~1/R/R-40~1.3/bin/x64" -lR ; \
"C:/rtools40/mingw64/bin/"g++ -shared -s -static-libgcc -o file9746d052a95.dll tmp.def file9746d052a95.o "C:/Users/wewol/OneDrive/Documents/R/win-library/4.0/rstan/lib/x64/libStanServices.a" -L"C:/Users/wewol/OneDrive/Documents/R/win-library/4.0/StanHeaders/libs/x64" -lStanHeaders -L"C:/Users/wewol/OneDrive/Documents/R/win-library/4.0/RcppParallel/lib/x64" -ltbb -L"C:/PROGRA~1/R/R-40~1.3/bin/x64" -lR ; \
rm -f tmp.def; \
fi \
fi
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/wewol/OneDrive/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'; file9746d052a95.o:file9746d052a95.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/wewol/OneDrive/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>(long double)::QS'; file9746d052a95.o
Error in sink(type = "output") : invalid connection
RStan Version:
packageVersion("rstan")
[1] ‘2.21.2’
R Version:
The version of R you are running (e.g., from R.version.string)
> R.version.string
[1] "R version 4.0.3 (2020-10-10)"
Operating System:
Windows 10.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the stanc() and stan_model() calls from the issue with rstan 2.21.2 on R 4.0.3 and Windows 10. Inspect the compileCode linker output, including the generated file9746d052a95.cpp and libStanServices.a, to determine the source of the duplicate Boost symbols. Done means the supplied model compiles successfully on the reported Windows setup without the multiple-definition error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, r
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100