c++boostcudanvccnoncopyable

Build a .cu file that uses boost


I ran the following command:

nvcc -arch=sm_70 foo.cu -o predatorPrey -I $BOOST_ROOT -L $BOOST_LIBRARY_PATH -lboost_timer

And got the following compilation error:

boost/include/boost/core/noncopyable.hpp(42): error: defaulted default constructor cannot be constexpr because the corresponding implicitly declared default constructor would not be constexpr

A google search led me here.

All hope seemed lost until this guy used a workaround. Though, as a junior programmer, I don't understand what he means by

Built boost from source with g++11 open solved the problem

Does that mean rebuilding boost from scratch? How is it different from building boost by default?

So what are actually the workarounds to use both and CUDA in the same project?


Solution

  • For host code usage:

    The only general workaround with a high probability of success when building a 3rd party library with the CUDA toolchain is to arrange your project in such a way that the 3rd party code is in a file that ends in .cpp and is processed by the host compiler (e.g. g++ on linux, cl.exe on windows).

    Your CUDA code (e.g. kernels, etc.) will need to be in files with filenames ending in .cu (for default processing behavior).

    If you need to use this 3rd party code/library functionality in your functions that are in the .cu file(s), you will need to build wrapper functions in your .cpp files to provide the necessary behavior as callable functions, then call these wrapper functions as needed from your .cu file(s).

    Link all this together at the project level.

    It may be that other approaches can be taken if the specific issue is analyzed. For example, sometimes updating to the latest version of the 3rd party library and/or CUDA version, may resolve the issue.

    For usage in device code:

    There is no general compatibility approach. If you expect some behavior to be usable in device code, and you run into a compile error like this, you will need to address the issue specifically.

    General suggestions may still apply, such as update to the latest version of the 3rd party library you are using, and/or latest CUDA version.