ANSI C99 and POSIX compliant compilers include functions
lgamma for computing the gamma function and its natural logarithm respectively. Visual Studio, however, does not support these standards.
Why are there separate functions for gamma and its logarithm? See this post for an explanation.
Here is stand-alone C++ code for the functions
LogGamma. Both require a positive argument.
Note that the functions
LogGamma are mutually dependent, but do not depend on anything else.