error: in call to ‘sample’

86 views
Skip to first unread message

Angel Berihuete

unread,
Oct 18, 2013, 11:14:03 AM10/18/13
to stan-...@googlegroups.com
Hi everyone!

I am trying to install Stan in the computer cluster of my University. Apparently the installation was done without errors (some warnings). Also the sentence 

bin/stanc --name=bernoulli --o=bernoulli.cpp src/models/basic_estimators/bernoulli.stan

works without errors. But then something wrong happens:

g++ -O3 -Lbin -Isrc -Ilib/boost_1.54.0 -Ilib/eigen_3.2.0 src/models/basic_estimators/bernoulli.cpp -o bernoulli -lstan

In file included from src/stan/model/model_header.hpp:20,
                 from src/models/basic_estimators/bernoulli.cpp:3:
src/stan/mcmc/sample.hpp: In function ‘int stan::gm::command(int, const char**) [with Model = bernoulli_model_namespace::bernoulli_model]’:
src/models/basic_estimators/bernoulli.cpp:273:   instantiated from here
src/stan/mcmc/sample.hpp:11: error: ‘class stan::mcmc::sample’ is not a function,
src/stan/gm/command.hpp:157: error:   conflict with ‘template<class Model, class RNG> void stan::gm::sample(stan::mcmc::base_mcmc*, int, int, int, int, bool, stan::io::mcmc_writer<Model>&, stan::mcmc::sample&, Model&, RNG&)’
src/stan/gm/command.hpp:887: error:   in call to ‘sample’ 

Any help would be welcome
Best regards
Angel

Bob Carpenter

unread,
Oct 18, 2013, 4:45:33 PM10/18/13
to stan-...@googlegroups.com


On 10/18/13 11:14 AM, Angel Berihuete wrote:
> Hi everyone!
>
> I am trying to install Stan in the computer cluster of my University. Apparently the installation was done without
> errors (some warnings). Also the sentence
>
> /bin/stanc --name=bernoulli --o=bernoulli.cpp src/models/basic_estimators/bernoulli.stan

This writes bernoulli.cpp in the current directory.

> works without errors. But then something wrong happens:

> /g++ -O3 -Lbin -Isrc -Ilib/boost_1.54.0 -Ilib/eigen_3.2.0 src/models/basic_estimators/bernoulli.cpp -o //bernoulli -lstan/

whereas this one looks for the .cpp file here
src/models/basic_estimators/bernoulli.cpp

We just checked the manual, and it looks like the instructions
there are correct.

- Bob

Jonathan French

unread,
Nov 7, 2013, 11:07:40 AM11/7/13
to stan-...@googlegroups.com
I get the same error messages when I try to compile the bernoulli model.

I've installed stan under Ubuntu with make version 3.81 and g++ version 4.4.3.  I don't seem to have any issues with the installation and the translation to C++ seems fine.  The error is when I compile.  

Was there a solution to this issue?

Thanks
Jonathan

Daniel Lee

unread,
Nov 7, 2013, 11:56:01 AM11/7/13
to stan-...@googlegroups.com
On Thu, Nov 7, 2013 at 11:07 AM, Jonathan French <jona...@metrumrg.com> wrote:
I get the same error messages when I try to compile the bernoulli model.

I've installed stan under Ubuntu with make version 3.81 and g++ version 4.4.3.  I don't seem to have any issues with the installation and the translation to C++ seems fine.  The error is when I compile.  

Was there a solution to this issue?


Yes, the issue is a user error. Bob explained in his email, but I'll give it another try. If you want to be less error prone, try using the makefiles provided. For help, just type 'make' on the command line and it'll show you an example of how to compile the normal model.


I'll assume that bin/stanc has been built. This line translates from a Stan model 'src/models/basic_estimators/bernoulli.stan' and generates a C++ file in './bernoulli.cpp':
> bin/stanc --name=bernoulli --o=bernoulli.cpp src/models/basic_estimators/bernoulli.stan

This line is incorrect because it is trying to compile the C++ file in './src/models/basic_estimators/bernoulli.cpp'
> g++ -O3 -Lbin -Isrc -Ilib/boost_1.54.0 -Ilib/eigen_3.2.0 src/models/basic_estimators/bernoulli.cpp -o bernoulli -lstan

To fix it, it should be:
> g++ -O3 -Lbin -Isrc -Ilib/boost_1.54.0 -Ilib/eigen_3.2.0 bernoulli.cpp -o bernoulli -lstan



Hopefully that fixes your problem.





On Friday, October 18, 2013 11:14:03 AM UTC-4, Angel Berihuete wrote:
Hi everyone!

I am trying to install Stan in the computer cluster of my University. Apparently the installation was done without errors (some warnings). Also the sentence 

bin/stanc --name=bernoulli --o=bernoulli.cpp src/models/basic_estimators/bernoulli.stan

works without errors. But then something wrong happens:

g++ -O3 -Lbin -Isrc -Ilib/boost_1.54.0 -Ilib/eigen_3.2.0 src/models/basic_estimators/bernoulli.cpp -o bernoulli -lstan

In file included from src/stan/model/model_header.hpp:20,
                 from src/models/basic_estimators/bernoulli.cpp:3:
src/stan/mcmc/sample.hpp: In function ‘int stan::gm::command(int, const char**) [with Model = bernoulli_model_namespace::bernoulli_model]’:
src/models/basic_estimators/bernoulli.cpp:273:   instantiated from here
src/stan/mcmc/sample.hpp:11: error: ‘class stan::mcmc::sample’ is not a function,
src/stan/gm/command.hpp:157: error:   conflict with ‘template<class Model, class RNG> void stan::gm::sample(stan::mcmc::base_mcmc*, int, int, int, int, bool, stan::io::mcmc_writer<Model>&, stan::mcmc::sample&, Model&, RNG&)’
src/stan/gm/command.hpp:887: error:   in call to ‘sample’ 

Any help would be welcome
Best regards
Angel
--
You received this message because you are subscribed to the Google Groups "stan users mailing list" group.
To unsubscribe from this group and stop receiving emails from it, send an email to stan-users+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Jonathan French

unread,
Nov 7, 2013, 12:39:28 PM11/7/13
to
Daniel,

Thanks for the reply.  It probably is an error on my part, but I get the same errors when I run directly using make.  Using the example in make help, I get:

/data/stan# make src/models/basic_distributions/normal


--- Translating Stan model to C++ code ---
bin/stanc src/models/basic_distributions/normal.stan --o=src/models/basic_distributions/normal.cpp
Model name=normal_model
Input file=src/models/basic_distributions/normal.stan
Output file=src/models/basic_distributions/normal.cpp
g++ -I src -isystem lib/eigen_3.2.0 -isystem lib/boost_1.54.0 -Wall -DBOOST_RESULT_OF_USE_TR1 -DBOOST_NO_DECLTYPE -DBOOST_DISABLE_ASSERTS -c -O3 -o src/models/basic_distributions/normal.o src/models/basic_distributions/normal.cpp

In file included from src/stan/model/model_header.hpp:20,
from src/models/basic_distributions/normal.cpp:3:
src/stan/mcmc/sample.hpp: In function ‘int stan::gm::command(int, const char**) [with Model = normal_model_namespace::normal_model]’:
src/models/basic_distributions/normal.cpp:241: instantiated from here
src/stan/mcmc/sample.hpp:11: error: ‘class stan::mcmc::sample’ is not a function,
src/stan/gm/command.hpp:157: error: conflict with ‘template<class Model, class RNG> void stan::gm::sample(stan::mcmc::base_mcmc*, int, int, int, int, bool, stan::io::mcmc_writer<Model>&, stan::mcmc::sample&, Model&, RNG&)’
src/stan/gm/command.hpp:904: error: in call to ‘sample’
src/stan/math/constants.hpp: At global scope:
src/stan/math/constants.hpp:63: warning: ‘stan::math::NEGATIVE_EPSILON’ defined but not used
src/stan/agrad/rev/var_stack.hpp:49: warning: ‘void stan::agrad::free_memory()’ defined but not used
make: *** [src/models/basic_distributions/normal.o] Error 1

Daniel Lee

unread,
Nov 7, 2013, 12:48:28 PM11/7/13
to stan-...@googlegroups.com
Ok. There's definitely a problem. The g++ line is missing the options specifying the stan library. The g++ line above should be:
g++ -I src -isystem lib/eigen_3.2.0 -isystem lib/boost_1.54.0 -Wall -DBOOST_RESULT_OF_USE_TR1 -DBOOST_NO_DECLTYPE -DBOOST_DISABLE_ASSERTS -c -O3 -o src/models/basic_distributions/normal.o src/models/basic_distributions/normal.cpp -Lbin -lstan

Would you mind trying that from the command line and seeing if that succeeds?

Just to double check, you're still on:
Ubuntu with make version 3.81 and g++ version 4.4.3

Can you type "make" on the command line and paste the top portion? The LDLIBS variable should be set to "-Lbin -lstan", but it looks like that has been erased somehow.


Daniel



On Thu, Nov 7, 2013 at 12:38 PM, Jonathan French <jona...@metrumrg.com> wrote:
Daniel,

Thanks for the reply.  It probably is an error on my part, but I get the same errors when I run directly using make.  Using the example in make help, I get:

/data/stan# make src/models/basic_distributions/normal


--- Translating Stan model to C++ code ---
bin/stanc src/models/basic_distributions/normal.stan --o=src/models/basic_distributions/normal.cpp
Model name=normal_model
Input file=src/models/basic_distributions/normal.stan
Output file=src/models/basic_distributions/normal.cpp
g++ -I src -isystem lib/eigen_3.2.0 -isystem lib/boost_1.54.0 -Wall -DBOOST_RESULT_OF_USE_TR1 -DBOOST_NO_DECLTYPE -DBOOST_DISABLE_ASSERTS -c -O3 -o src/models/basic_distributions/normal.o src/models/basic_distributions/normal.cpp
In file included from src/stan/model/model_header.hpp:20,
from src/models/basic_distributions/normal.cpp:3:
src/stan/mcmc/sample.hpp: In function ‘int stan::gm::command(int, const char**) [with Model = normal_model_namespace::normal_model]’:
src/models/basic_distributions/normal.cpp:241: instantiated from here
src/stan/mcmc/sample.hpp:11: error: ‘class stan::mcmc::sample’ is not a function,
src/stan/gm/command.hpp:157: error: conflict with ‘template<class Model, class RNG> void stan::gm::sample(stan::mcmc::base_mcmc*, int, int, int, int, bool, stan::io::mcmc_writer<Model>&, stan::mcmc::sample&, Model&, RNG&)’
src/stan/gm/command.hpp:904: error: in call to ‘sample’
src/stan/math/constants.hpp: At global scope:
src/stan/math/constants.hpp:63: warning: ‘stan::math::NEGATIVE_EPSILON’ defined but not used
src/stan/agrad/rev/var_stack.hpp:49: warning: ‘void stan::agrad::free_memory()’ defined but not used
make: *** [src/models/basic_distributions/normal.o] Error 1


On Thursday, November 7, 2013 11:56:01 AM UTC-5, Daniel Lee wrote:
On Thu, Nov 7, 2013 at 11:07 AM, Jonathan French <jona...@metrumrg.com> wrote:
I get the same error messages when I try to compile the bernoulli model.

I've installed stan under Ubuntu with make version 3.81 and g++ version 4.4.3.  I don't seem to have any issues with the installation and the translation to C++ seems fine.  The error is when I compile.  

Was there a solution to this issue?


Yes, the issue is a user error. Bob explained in his email, but I'll give it another try. If you want to be less error prone, try using the makefiles provided. For help, just type 'make' on the command line and it'll show you an example of how to compile the normal model.


I'll assume that bin/stanc has been built. This line translates from a Stan model 'src/models/basic_estimators/bernoulli.stan' and generates a C++ file in './bernoulli.cpp':
> bin/stanc --name=bernoulli --o=bernoulli.cpp src/models/basic_estimators/bernoulli.stan

This line is incorrect because it is trying to compile the C++ file in './src/models/basic_estimators/bernoulli.cpp'
> g++ -O3 -Lbin -Isrc -Ilib/boost_1.54.0 -Ilib/eigen_3.2.0 src/models/basic_estimators/bernoulli.cpp -o bernoulli -lstan

To fix it, it should be:
> g++ -O3 -Lbin -Isrc -Ilib/boost_1.54.0 -Ilib/eigen_3.2.0 bernoulli.cpp -o bernoulli -lstan



Hopefully that fixes your problem.




Daniel Lee

unread,
Nov 7, 2013, 12:51:50 PM11/7/13
to stan-...@googlegroups.com
Hang on -- that wasn't quite right. Could you paste the result of "make" from the command line?

Jonathan French

unread,
Nov 7, 2013, 12:57:57 PM11/7/13
to stan-...@googlegroups.com
Yes, I'm still on the same system.  The top portion of the make output is
Stan makefile:
  Current configuration:
  - OS (Operating System):    linux
  - CC (Compiler):            g++
  - Compiler version:         4.4
  - O (Optimization Level):   3
  - O_STANC (Opt for stanc):  0
  - STAN_HOME                 ./
  Library configuration:
  - EIGEN                     lib/eigen_3.2.0
  - BOOST                     lib/boost_1.54.0
  - GTEST                     lib/gtest_1.7.0

The g++ line still returns the same errors as before:

/data/stan# g++ -I src -isystem lib/eigen_3.2.0 -isystem lib/boost_1.54.0 -Wall -DBOOST_RESULT_OF_USE_TR1 -DBOOST_NO_DECLTYPE -DBOOST_DISABLE_ASSERTS -c -O3 -o src/models/basic_distributions/normal.o src/models/basic_distributions/normal.cpp -Lbin -lstan
In file included from src/stan/model/model_header.hpp:20,
                 from src/models/basic_distributions/normal.cpp:3:
src/stan/mcmc/sample.hpp: In function ‘int stan::gm::command(int, const char**) [with Model = normal_model_namespace::normal_model]’:
src/models/basic_distributions/normal.cpp:241:   instantiated from here
src/stan/mcmc/sample.hpp:11: error: ‘class stan::mcmc::sample’ is not a function,
src/stan/gm/command.hpp:157: error:   conflict with ‘template<class Model, class RNG> void stan::gm::sample(stan::mcmc::base_mcmc*, int, int, int, int, bool, stan::io::mcmc_writer<Model>&, stan::mcmc::sample&, Model&, RNG&)’
src/stan/gm/command.hpp:904: error:   in call to ‘sample’
src/stan/math/constants.hpp: At global scope:
src/stan/math/constants.hpp:63: warning: ‘stan::math::NEGATIVE_EPSILON’ defined but not used
src/stan/agrad/rev/var_stack.hpp:49: warning: ‘void stan::agrad::free_memory()’ defined but not used

Thanks,
Jonathan

Daniel Lee

unread,
Nov 7, 2013, 1:02:17 PM11/7/13
to stan-...@googlegroups.com
Do you happen to have another compiler installed? I'm trying to install g++ 4.4 on my Mac (hopefully they're compatible). That error message looks like the compiler is having some trouble -- I'll do what I can to reproduce the issue on my end.


Daniel


Daniel Lee

unread,
Nov 7, 2013, 1:51:59 PM11/7/13
to stan-...@googlegroups.com
I just verified that it doesn't compile using g++ v4.4.

I get the same error novel. Do you have access to a different compiler? I don't have time to hunt down what is incompatible with g++ 4.4 right now, but hopefully one of us can get to it soon.


Daniel

Daniel Lee

unread,
Nov 7, 2013, 1:54:50 PM11/7/13
to stan-...@googlegroups.com
I just created an issue for it, if you wanted to track progress. #375: https://github.com/stan-dev/stan/issues/375

Jonathan French

unread,
Nov 7, 2013, 2:24:49 PM11/7/13
to stan-...@googlegroups.com
Thanks, Daniel.  We can update our compiler to a newer version.  That sounds like it will probably solve the issue.

Thanks again
Jonathan
Reply all
Reply to author
Forward
0 new messages