Hi,
I’ve been having a problem compiling a code I have that uses the Boost libraries, and fails to compile straight C++ (no CUDA) code.
I’ve searched the forums and couldn’t find any reference to it.
I’ve managed to trace it to the following minimal example (filename boostTestFunc.cu)
[codebox]
// Testing Boost Functional with CUDA
#include <boost/functional/hash.hpp>
int main(void)
{
boost::hash float_hash;
return 0;
}
[/codebox]
My code uses more general Boost libraries, in particular the Functional library, which end up including this one, so it’s not just a matter of working around this one include file.
I am using Ubuntu 10.4, with nvcc 3.2RC, and this gives the following error:
[codebox]
$ nvcc boostTestFunc.cu -o boostTestFunc -I /opt/boost-1.44.0-gcc/include/
boostTestFunc.cu(7): warning: variable “float_hash” was declared but never referenced
/usr/include/c++/4.4/cmath(500): error: identifier “__builtin_fpclassify” is undefined
detected during:
instantiation of "__gnu_cxx::__enable_if<std::__is_arithmetic<_Tp>::__value, int>::__type std::fpclassify(_Tp) [with _Tp=float]"
/opt/boost-1.44.0-gcc/include/boost/functional/hash/detail/hash_float.hpp(65): here
instantiation of "size_t boost::hash_detail::float_hash_value(T) [with T=float]"
/opt/boost-1.44.0-gcc/include/boost/functional/hash/hash.hpp(315): here
/usr/include/c++/4.4/cmath(500): error: identifier “__builtin_fpclassify” is undefined
detected during:
instantiation of "__gnu_cxx::__enable_if<std::__is_arithmetic<_Tp>::__value, int>::__type std::fpclassify(_Tp) [with _Tp=double]"
/opt/boost-1.44.0-gcc/include/boost/functional/hash/detail/hash_float.hpp(65): here
instantiation of "size_t boost::hash_detail::float_hash_value(T) [with T=double]"
/opt/boost-1.44.0-gcc/include/boost/functional/hash/hash.hpp(320): here
/usr/include/c++/4.4/cmath(500): error: identifier “__builtin_fpclassify” is undefined
detected during:
instantiation of "__gnu_cxx::__enable_if<std::__is_arithmetic<_Tp>::__value, int>::__type std::fpclassify(_Tp) [with _Tp=long double]"
/opt/boost-1.44.0-gcc/include/boost/functional/hash/detail/hash_float.hpp(65): here
instantiation of "size_t boost::hash_detail::float_hash_value(T) [with T=long double]"
/opt/boost-1.44.0-gcc/include/boost/functional/hash/hash.hpp(325): here
3 errors detected in the compilation of “/tmp/tmpxft_00004137_00000000-4_boostTestFunc.cpp1.ii”.
[/codebox]
This uses the default Ubuntu 10.4 compiler - gcc 4.4.3 (Ubuntu 4.4.3-4ubuntu5)
However, if I use gcc 4.3.4 (Ubuntu 4.3.4-10ubuntu1), then:
[codebox]
$ nvcc boostTestFunc.cu -o boostTestFunc -I /opt/boost-1.44.0-gcc/include/ --compiler-bindir=/opt/gcc-4.3
boostTestFunc.cu(7): warning: variable “float_hash” was declared but never referenced
boostTestFunc.cu(7): warning: variable “float_hash” was declared but never referenced
[/codebox]
Note: /opt/gcc-4.3 just contains a symlink to the appropriate gcc binary, and I’m using Boost version 1.44.0, built with the gcc toolset.
Are there any known workarounds/solutions to this, or is this a problem with nvcc compatibility with gcc 4.4, or with the Boost libraries?