Compiler message for stan?



Yes, RStan 2.16 fixed the bug that was introduced in the refactor for 2.15.


The error happened under rstan_2.16.2.


It’s bash.

They are put inside ~/.bashrc (linux) or ~/.bash_profile (osx)

And then remember to source ~/.bashrc / source ~/.bash_profile (or restart).


This also works, but you need the -C option:

make -C $CMDSTAN_DIR /absolute/path/to/model/name


@bhomass, it’s easy enough to build a script to build CmdStan executables from the command line. Here are the steps necessary:

  1. Build the Stan compiler (bin/stanc).
  2. Optional: build the CVODES library.
  3. Use the Stan compiler to compile a Stan program to a C++ header file.
  4. Compile an executable using the generated C++ header file and the src/cmdstan/main.cpp, optionally linking with the CVODES library.

The makefile in CmdStan currently handles all of that for you. It makes it seamless if you wanted to jump straight to 4 without going through all of the steps individually.

GNU make does not handle spaces in target names. (There’s no way to escape the space either!) Space separates targets in make, so there’s just no way around it.

If you’re never going to have spaces anywhere in your paths, you should be able to do this:

make -f <path to CmdStan>/make <Stan program dropping the .stan extension>

This may not work if we haven’t used the right root path everywhere.

What @sakrejda looks promising, but once again, is restricted to paths without spaces.

If you do what @aaronjg suggests and look at the output of the -n option, you should be able to directly write the calls to the compiler with the right options. That will work with spaces as long as it’s escaped properly. That’s the part that you can actually script if you’re inclined to do so.

In CmdStan, we could have scripts instead of make, but it’s actually a technical challenge and burden to maintain a custom build system. If anyone has ways to do it better and robustly across enough of our users, please let us know. I don’t think any of the devs claim to be build system experts.


neither worked.

make -f /installpath/cmdstan-2.16.0/makefile mymodel fails with

— Linking C++ model —
g++ -I src -I stan/src -isystem stan/lib/stan_math/ -isystem -isystem -isystem /include -Wall -DEIGEN_NO_DEBUG -DBOOST_RESULT_OF_USE_TR1 -DBOOST_NO_DECLTYPE -DBOOST_DISABLE_ASSERTS -DFUSION_MAX_VECTOR_SIZE=12 -DNO_FPRINTF_OUTPUT -pipe -O3 -o AdAttrib -include AdAttrib.hpp -include ./USER_HEADER.hpp
clang: error: no input files
make: *** [AdAttrib] Error 1

make -C $stan_path mymodel fails with

make: *** No rule to make target `AdAttrib’. Stop.

I would help figure this out, but I am also no system / build developer.


Mymodel needs to be in fullpath-format. Also, it should be make not makefile.

edit. Sorry, you are using -f. My suggestions are for -C.


tried fullpath for model, make and makefile both. None worked.


Try this


that too. same error
— Linking C++ model —
g++ …


$CMDSTAN is the root CmdStan folder, not make or makefile.


correct. got that. I had two efforts going on as reported in my response above. One using -C with the directory. The other with -f where I tried make and makefile.


Do you have space in your fullpath?


no space. in addition, I am running this right in the same directory as the model, so I tried simply ./model as well.


Can you show the results from these

echo $stan_path
echo <path_to_model_here>


Just fyi, regardless of how frustrating troubleshooting is, posting “none worked” without the command + output makes it impossible to help you. It’s also irritating for anyone who tries.


‘make -C’ only works with an absolute path to the target model binary.


I am not frustrated, just moving along and reporting progress. Output is higher up in this thread. For clarity, I have already compiled .stan file into .cpp and .hpp. I am trying to now create the binary from either these intermediary files or from the original .stan file. So to respond to your post, having a make -C work with a binary is of no relevance, because I don’t have that model binary yet.

I am curious though, if you already have the model binary, what would be the point of calling make -C after that?


Hi, you call -C fullpath to mymodel.stan (excluding .stan)

make -C $stan_path /home/stanfiles/mymodel

This will create a compiled binaryfile mymodel that you can sample.


Oh, that does work. However, the idea is to be work inside my working direct, where mymodel.stan resides. So that I can call mymodel without the full path, or at least be able to call ./mymodel (which currently fails).

If it is necessary to call fullpath/mymodel, then this is worse off than working in the cmdstan install directory, where at least I can skip -C. So at the end it still comes down to not having a convenient to call up an executable inside the working directory for the model file.

I think if someone comes up with a bash shell which fills in the current working directory to fill in the front part of the model file name, or interpret a ./ designation, it would achieve the desired effect.