Hello all,
I am having issues with using external C++ code in conjunction with Cmdstan. I am following the documentation listed here: 22 Using external C++ code. I am following these instrunctions with the end goal of accomplishing what Ben Goodrich described in his answer for this Stack Overflow question: Calling Stan routines from a C++ program.
I have installed Cmdstand on my Ubuntu 20.04 amd64 machine using the latest release here: Cmdstan v2.29.2 (25 March 2022)
The installation process I followed: I downloaded the installation labeled as cmdstan-2.29.2.tar.gz . Once the tar.gz was downloaded and unzipped into my home directory, I opened a terminal window and cd into ~/cmdstan-2.29.2/. From that directory, I called āmake clean-allā and then āmake buildā and the installation processes was completed without errors.
To test that the installation was successful, I ran the bernoulli example using these steps: 1 CmdStan Installation | CmdStan Userās Guide. This test was completed without errors.
This is where things fell apart. From here, I went ahead and tried the external c++ code functionality. Based on this documentation, I had to edit the bernoulli.stan file, add a make_odds.hpp file, and call the make command with the two flags. I will attach the bernoulli.stan and make_odds.hpp files that I used. This was the make call that I used:
make STANCFLAGS=--allow_undefined USER_HEADER=examples/bernoulli/make_odds.hpp examples/bernoulli/bernoulli
I did this and I got back errors. Iāve tried this on a fresh install of Cmdstan and end up with the same errors.
There is a deprecated notice for the --allow_undefined
flag listed in the documentation, but using the non-deprecated flag results in the same errors. I will attach the .hpp file that is the result of the screenshot above.
Here is the g++ and make versions that I used.
I have cross-referenced the code that I am using with the code listed for cmdstanpy here: cmdstanpy/docstr/examples.
- Operating System: Ubuntu 20.04 amd64
- CmdStan Version: v2.29.2
- Compiler/Toolkit: g++ 9.4.0 and make 4.2.1
Thank you for any help you can offer.
-Matt
bernoulli.hpp (14.5 KB)
make_odds.hpp (319 Bytes)
bernoulli.stan (309 Bytes)