Search code examples
c++11c++buildermath.hcmathgamma

What to do if tgamma() function is not defined?


I am trying to use tgamma() from the standard library. When I try to compile, I get the error message:

Call to undefined function tgamma

I have the directive #include <cmath>. I use Embarcadero C++ Builder XE3, which claims to support C++11 standards. What could be my problem, and how to fix it?


Solution

  • Boost contains a tgamma function.

    #include <boost/math/special_functions/gamma.hpp>
    ...
    double rootPi = boost::math::tgamma<double>(0.5);
    

    Of course, you can always switch to a different compiler, like gcc.