Issue compiling bernoulli example model in cmdstan 2.17

Operating System: Fedora 26 (kernel 4.13)
Interface Version: 2.17.0
Compiler/Toolkit: gcc 7.2.1

Hi everyone,

I’m a reasonably experienced user of pystan but to resolve some compatibility issues I’m trying to switch some of my work over to cmdstan.

I’ve built all the submodules and run the tests with the “” script without any issues, however upon trying to run the bernoulli example I’m receiving an error.

I run:

make examples/bernoulli/bernoulli

from the cmdstan base directory and receive an error from (I think?) gcc:

cc1plus: fatal error: -pch: No such file or directory

This occurs during linking the c++ model, at which point the compilation is terminated.

Any advice on how to troubleshoot this would be appreciated - I’ve had a quick search but have found nothing helpful so far.

Can you post the entire compiler invocation, starting with the line beginning with g++/clang++

Of course - silly of me not to have posted this before:

make examples/bernoulli/bernoulli

— Linking C++ model —
g++ -Wall -I . -isystem stan/lib/stan_math/lib/eigen_3.3.3 -isystem stan/lib/stan_math/lib/boost_1.64.0 -isystem stan/lib/stan_math/lib/cvodes_2.9.0/include -std=c++1y -DBOOST_RESULT_OF_USE_TR1 -DBOOST_NO_DECLTYPE -DBOOST_DISABLE_ASSERTS -DBOOST_PHOENIX_NO_VARIADIC_EXPRESSION -Wno-unused-function -Wno-uninitialized -I src -I stan/src -isystem stan/lib/stan_math/ -DEIGEN_NO_DEBUG -DFUSION_MAX_VECTOR_SIZE=12 -DNO_FPRINTF_OUTPUT -pipe -lpthread -include-pch stan/src/stan/model/model_header.hpp.gch -O3 -o examples/bernoulli/bernoulli src/cmdstan/main.cpp -include examples/bernoulli/bernoulli.hpp stan/lib/stan_math/lib/cvodes_2.9.0/lib/libsundials_nvecserial.a stan/lib/stan_math/lib/cvodes_2.9.0/lib/libsundials_cvodes.a
cc1plus: fatal error: -pch: No such file or directory
compilation terminated.
make: *** [make/models:16: examples/bernoulli/bernoulli] Error 1

This is a makefile bug. @seantalts @syclik just pinging you so you see this.

clang++ uses the -include-pch flag but g++ just includes precompiled headers automatically if they are in the same directory as the original header. So here g++ is interpreting -include-pch as the -include flag with -pch as the value so it can’t find the file called -pch.

For Daniel and Sean: This would all be much easier to resolve if we didn’t have to have pull so much makefile magic from the math lib. Could we just make separate makefiles for CmdStan and only pull the really generic ones from the math lib like identifying compiler and os?

This bug is what my PR from Nov 8 fixes:

I recently intentionally refactored the makefiles to share more code and settings because there was a ton of duplication. Maybe I went too far, though I don’t think this bug speaks to that question in either direction as its just in the CmdStan makefile and doesn’t have anything to do with the Stan or Math repo makefiles the CmdStan repo includes.

1 Like

@sakrejda, thanks. I missed the first message.

I think this was the cause of it. It was the right thing to do… I don’t think we realized how far-reaching the effects would be. I’ll take action to walk through the makefiles before releasing the next CmdStan version. Hopefully this week.

I haven’t had a chance to test that it works. I think for these makefile fixes, we should be making sure it compiles against Win, Mac, and Linux. I know we have all three at Columbia, so I’ll try running it there before approving.

1 Like

Thanks Sean, I didn’t want it to get missed.

Thanks for the explanation everyone -

Is there a fix I can implement immediately or should I wait for a patch?

(apologies if this is obvious)

If you don’t mind editing the makefiles you can find the -include-pch flag in there and remove it (and whatever was getting included like that). Or you can clone cmdstan develop which (I think) has this fixed.

I’ll try cloning the development version.

Thanks once again!

2.17.1 is also out now in case that helps.

I get the same error with a fresh install of cmdstan 2.17.1. See attached dump of the command line output (I’m on Windows…). Is this a bug on my machine? Any idea on how I can fix it?

error.txt (13.9 KB)

It looks like the CVODES library wasn’t built properly. Can you try this:

make build

Then try to build the Bernoulli executable again?

make examples/bernoulli/bernoulli.exe

If this works, there’s a slight problem in the makefiles that we can fix.

One additional question:

  1. What version of Windows are you on?
1 Like

Embarrassing - seems I forgot to “make build”!

It works now. Thank you for a very fast response.

That’s not embarrassing! That’s an actual issue; we’ll need to fix that for the next release. It should have built automatically.

Thanks for writing in and letting us know. It works automatically for linux and mac and we just don’t have a lot of testing in place for Windows.