Hi all,
I’m experimenting with some new features, using branches try-laplace_student
for the math
repository and try-laplace_approximation2
for the stanc3 repository. The code passes the unit tests I wrote for both repos, I however get an error when trying to compile a Stan model using cmdstan.
Here’s the command
make examples/bernoulli/bernoulli
and the output
--- Compiling, linking C++ code ---
clang++ -std=c++1y -Wno-unknown-warning-option -Wno-tautological-compare -Wno-sign-compare -D_REENTRANT -Wno-ignored-attributes -I stan/lib/stan_math/lib/tbb_2020.3/include -O3 -I src -I stan/src -I lib/rapidjson_1.1.0/ -I lib/CLI11-1.9.1/ -I stan/lib/stan_math/ -I stan/lib/stan_math/lib/eigen_3.3.9 -I stan/lib/stan_math/lib/boost_1.75.0 -I stan/lib/stan_math/lib/sundials_5.7.0/include -DBOOST_DISABLE_ASSERTS -c -include-pch stan/src/stan/model/model_header.hpp.gch -x c++ -o examples/bernoulli/bernoulli.o examples/bernoulli/bernoulli.hpp
clang++ -std=c++1y -Wno-unknown-warning-option -Wno-tautological-compare -Wno-sign-compare -D_REENTRANT -Wno-ignored-attributes -I stan/lib/stan_math/lib/tbb_2020.3/include -O3 -I src -I stan/src -I lib/rapidjson_1.1.0/ -I lib/CLI11-1.9.1/ -I stan/lib/stan_math/ -I stan/lib/stan_math/lib/eigen_3.3.9 -I stan/lib/stan_math/lib/boost_1.75.0 -I stan/lib/stan_math/lib/sundials_5.7.0/include -DBOOST_DISABLE_ASSERTS -Wl,-L,"/Users/charlesm/Code/laplace_approximation/spring2021/cmdstan/stan/lib/stan_math/lib/tbb" -Wl,-rpath,"/Users/charlesm/Code/laplace_approximation/spring2021/cmdstan/stan/lib/stan_math/lib/tbb" examples/bernoulli/bernoulli.o src/cmdstan/main.o -Wl,-L,"/Users/charlesm/Code/laplace_approximation/spring2021/cmdstan/stan/lib/stan_math/lib/tbb" -Wl,-rpath,"/Users/charlesm/Code/laplace_approximation/spring2021/cmdstan/stan/lib/stan_math/lib/tbb" stan/lib/stan_math/lib/sundials_5.7.0/lib/libsundials_nvecserial.a stan/lib/stan_math/lib/sundials_5.7.0/lib/libsundials_cvodes.a stan/lib/stan_math/lib/sundials_5.7.0/lib/libsundials_idas.a stan/lib/stan_math/lib/sundials_5.7.0/lib/libsundials_kinsol.a stan/lib/stan_math/lib/tbb/libtbb.dylib stan/lib/stan_math/lib/tbb/libtbbmalloc.dylib stan/lib/stan_math/lib/tbb/libtbbmalloc_proxy.dylib -o examples/bernoulli/bernoulli
duplicate symbol 'stan::math::block_matrix_sqrt(Eigen::SparseMatrix<double, 0, int>, int)' in:
examples/bernoulli/bernoulli.o
src/cmdstan/main.o
ld: 1 duplicate symbol for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [examples/bernoulli/bernoulli] Error 1
There seems to be an error with a function I defined, namely block_matrix_sqrt
. My understanding of compilers is a bit limited, so I’m not quite sure how to check for this error. Any pointers are appreciated.
My guess is the function gets defined twice, however the relevant file does specify
#ifndef STAN_MATH_LAPLACE_BLOCK_MATRIX_SQRT_HPP
#define STAN_MATH_LAPLACE_BLOCK_MATRIX_SQRT_HPP
so even if the file is included twice, this shouldn’t be an issue, right?
Below is the shell script I used to install cmdstan
#! /bin/bash
git clone https://github.com/stan-dev/stanc3.git
cd stanc3
git checkout try-laplace_approximation2
cd ..
git clone https://github.com/stan-dev/cmdstan.git
cd cmdstan
make stan-update
cd stan
cd lib/stan_math
git checkout try-laplace_student
cd ..
cd ..
cd ..
# make build
STANC3=../stanc3