Why can't I use stanmath with vs2017 correctly ?

Operating System:windows10
Interface Version:math-develop
Compiler/Toolkit:vs2017
When I test a program
#include “pch.h”
#include
#include <stan/math.hpp>
int main(){
std::cout << “log normal(1 | 2, 3)=”
<< stan::math::normal_log(1, 2, 3)
<< std::endl;
}
But something problems unexpected happened,for example,
1、error C1189 #error: “stan-math requires _REENTRANT being defined during compilation” “to make lgamma_r available.”
2、error E0282 The global scope does not have this variable——“lgamma_r”
#if !MINGW32
int sign = 1;
return ::lgamma_r(x, &sign);
3、error C2672 “tcrossprod”: No matching overloads found
And Because this is my first contact with stanmath, I do not understand why these errors occur, and I have not found the corresponding answers on the Internet. I hope those who understand can answer for me, thank you very much.

It probably can be made to work with a sufficiently recent version of VS but none of the Stan developers are actively trying to get it to work it with VS, much less testing it thoroughly.

For error 1, you need to pass -D_REENTRANT as part of the compiler flags (i.e. along with the path to the Stan Math library and so forth). That will also probably fix error 2. I am not sure about error 3 because the tcrossprod function is not being called by your main function, but we can see about fixing that later.

Thank you very much for your answer,But I still can’t solve these problems very effectively。And I now just want to test the program successfully on Vs2017,I configured the environment according to http://mc-stan.org/math/index.html,Unfortunately i cannot run this simple program mentioned in this URL。So Could you help me,Thank you very much。

I can’t help you that much because, as I said, I don’t use VS and none of the other Stan developers do either. There should be documentation as to how to pass flags to the compiler, but you could also try compiling:

#define _REENTRANT 1
#include “pch.h”
#include
#include <stan/math.hpp>
int main(){
std::cout << “log normal(1 | 2, 3)=”
<< stan::math::normal_log(1, 2, 3)
<< std::endl;
}

Thank you very much for your answer, I will try again later to see if I can solve the problem。

Hi, what are you trying to do with Visual Studio? I have built Stan Math with VS, but it is in a project fork using CMake. Is there some reason building with MinGW is unacceptable?

Hello,I try to use stan to deal with sinkhorn algorithm。But when I tested using stan, I found that as soon as I add the header file #include<stan/math.hpp>,I get errors that I mentioned above。