[Notes] Solve the error: redefinition of 'constexpr const _Tp encountered when compiling nvcc

1. Problems that occur when compiling with nvcc

/usr/include/c++/10/type_traits:71:52: error: redefinition of ‘constexpr const _Tp std::integral_constant<_Tp, __v>::value’
   71 |   template<typename _Tp, _Tp __v>
      |                                                    ^                           
/usr/include/c++/10/type_traits:59:29: note: ‘constexpr const _Tp value’ previously declared here
   59 |       static constexpr _Tp                  value = __v;
      |                             ^~~~~

2. After checking, the nvcc and gcc g++ versions do not match

ls /usr/include/c++

10/ 12/

3. Solve the problem after installing gcc g++ suitable for nvcc

sudo apt install gcc-11 g++-11

ls /usr/include/c++

10/ 11/ 12/

Guess you like

Origin blog.csdn.net/miles2007/article/details/132815538