Search code examples
c++clang++tr1cmath

How to compile special mathematical functions with clang?


One can call sph_legendre from tr1 and compile it with gcc-5 or gcc-6

#include<tr1/cmath>

int main()
{
    std::tr1::sph_legendre(1,1,0);
    return 0;
} 

Unfortunately, if I try to compile it with clang++ as:

clang++ -stdlib=libstdc++ legendre.cpp -o legendre

I get

error: no member named 'sph_legendre' in namespace 'std::tr1'

In the section 40.3, The C++PP (4th edition) states:

"There is a separate ISO standard for special mathematical functions [C++Math,2010]. An implementation may add these functions to cmath"

How can I compile these special functions with clang++?


Solution

  • As Richard already mentioned, clang does not support std::sph_legendre at the moment.

    A possible workaround for you is to use the boost libraries (http://www.boost.org) and include header: boost/math/tr1.hpp