Getting started as a developer - first steps

Hey guys,

this is Franzi and I am new on the developer side of Stan. In the future, I would like to contribute a new function to Stan and provide an interface to RStan. But now, I am stuck with the very first steps.

I cloned the GitHub respository math and try to get it run locally. I use Windows 10 and a Visual Studio Project that consists of all files in the math repository. I already included all necessary include-paths but there are still more than 800 error messages like this:

It seems that it does not recognise the Sundials Packages. Do I have to install Sundials first?

I would be very thankful for a response! Please let me know if any information is missing. Since I am new I am not yet familiar with formulating technical questions.

Best, Franzi


So what exactly did you try to run?

In Visual Studio I opened the project and one .hpp file.
Then it starts to do some background tasks. After finishing these tasks it shows all the error messages.

Sundials and other dependencies are in lib after cloning, but you need to build them, as explained in the Installation section here: GitHub - stan-dev/math: The Stan Math Library is a C++ template library for automatic differentiation of any order using forward, reverse, and mixed modes. It includes a range of built-in functions for probabilistic modeling, linear algebra, and equation solving.. Then you can build and run a program that uses stan math, like the example

#include <stan/math.hpp>
#include <iostream>

int main() {
  std::cout << "log normal(1 | 2, 3)="
            << stan::math::normal_log(1, 2, 3)
            << std::endl;

I don’t know much about VS Code or whether you can initialize the build process from there somehow.

1 Like

Just a warning that you probably need to use gcc / clang toolchain (not sure how these work with Visual Studio).

There have been some problems with MSVC before (template problems) but not sure what is the current situation.

1 Like

There is a page of tips in Doxygen which might be helpful: Stan Math Library: Windows Development Tips

As a worthwhile alternative, I use WSL2 with Ubuntu 20.04 which is IMO by far easier and better performing.


MSVC compiler is still not officially supported for Stan. It should work with the new UCRT toolchain, but have not tried it within Visual Studio yet.

I would second what @maedoc suggests, using WSL.


Thanks for your suggestion. I’m still struggling with Windows :sweat_smile: Now, I’ll try the way with WSL2.

Which program would you recommend to work with instead of Visual Studio?

Visual Studio Code works well with WSL2, just be sure to install the extension “Remote - WSL”.

Thanks a lot @jtimonen! Now with a WSL the example code runs :)