I am trying to compile a c++
file with nvcc
using cuda 7.5.18 and gcc 5.4.0 and am running into errors. Take the following simple example:
#include <thrust/functional.h>
struct test_struct {
//..
}
void f(test_struct& a) {
//..
}
int main() {
test_struct a;
std::function<void()> bound_f = std::bind(f, std::ref(a));
}
Compiling this code with nvcc -c -std=c++11 test.cu -o test.o
results in the following error output:
/usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/include/c++/functional(78): error: class "test_struct" has no member "result_type"
detected during:
instantiation of class "std::_Maybe_get_result_type<_Functor, void> [with _Functor=test_struct]"
(86): here
instantiation of class "std::_Weak_result_type_impl<_Functor> [with _Functor=test_struct]"
(184): here
instantiation of class "std::_Weak_result_type<_Functor> [with _Functor=test_struct]"
(264): here
instantiation of class "std::_Reference_wrapper_base_impl<true, true, _Tp> [with _Tp=test_struct]"
(283): here
instantiation of class "std::_Reference_wrapper_base<_Tp> [with _Tp=test_struct]"
(399): here
instantiation of class "std::reference_wrapper<_Tp> [with _Tp=test_struct]"
test.cu(14): here
/usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/include/c++/functional(266): error: class "test_struct" has no member "argument_type"
detected during:
instantiation of class "std::_Reference_wrapper_base_impl<true, true, _Tp> [with _Tp=test_struct]"
(283): here
instantiation of class "std::_Reference_wrapper_base<_Tp> [with _Tp=test_struct]"
(399): here
instantiation of class "std::reference_wrapper<_Tp> [with _Tp=test_struct]"
test.cu(14): here
/usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/include/c++/functional(267): error: class "test_struct" has no member "first_argument_type"
detected during:
instantiation of class "std::_Reference_wrapper_base_impl<true, true, _Tp> [with _Tp=test_struct]"
(283): here
instantiation of class "std::_Reference_wrapper_base<_Tp> [with _Tp=test_struct]"
(399): here
instantiation of class "std::reference_wrapper<_Tp> [with _Tp=test_struct]"
test.cu(14): here
/usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/include/c++/functional(268): error: class "test_struct" has no member "second_argument_type"
detected during:
instantiation of class "std::_Reference_wrapper_base_impl<true, true, _Tp> [with _Tp=test_struct]"
(283): here
instantiation of class "std::_Reference_wrapper_base<_Tp> [with _Tp=test_struct]"
(399): here
instantiation of class "std::reference_wrapper<_Tp> [with _Tp=test_struct]"
test.cu(14): here
5 errors detected in the compilation of "/tmp/tmpxft_00003b29_00000000-7_test.cpp1.ii".
I can't find anything nvcc related with the lines error: ... has no member "second_argument_type"
and so on, so I am completely clueless. Apparently the class members of std::function
are somehow not found (see here).
What can I do to work around this issue?