0

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?

Praetorian
  • 106,671
  • 19
  • 240
  • 328
  • Are you compiling for 32-bit or 64-bit? Only the 64-bit compiler supports C++11, the 32-bit compiler does not yet. If you are compiling for 64-bit, then are you calling tgamma using the `std` namespace? `... = std::tgamma(...);` – Remy Lebeau Apr 19 '13 at 23:40
  • How do I find out if I am compiling for 64-bit or not? I am on a 64-bit machine, but the IDE is installed in Program Files(x86). The compiler is supposed to support both 32-bit and 64-bit. – user2300944 Apr 19 '13 at 23:44
  • In the Project Manager, the **Target Platforms** node allows you to add individual platform(s) that your project supports, and to set which platform is active at any given time. There are separate compilers for 32-bit and 64-bit, Windows and Mac, so you have to tell the IDE which platform to compile for. – Remy Lebeau Apr 20 '13 at 01:40
  • possible duplicate of [gamma or log gamma function in C or C](http://stackoverflow.com/questions/15472803/gamma-or-log-gamma-function-in-c-or-c) – Cole Tobin Feb 21 '14 at 17:59

1 Answers1

1

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.

Cole Tobin
  • 9,206
  • 15
  • 49
  • 74