2

I'm having trouble building this one line program with nvcc:

#include <boost/container/small_vector.hpp>

The error log I'm getting looks as follows, to me it hints that maybe there is some marco definition conflict, but I'm not good enough with C++ to figure it out:

C:\Boost\include\boost-1_62\boost/container/small_vector.hpp(484): error C2332: 'struct': missing tag name
C:\Boost\include\boost-1_62\boost/container/small_vector.hpp(608): note: see reference to class template instantiation 'boost::container::small_vector<T,N,Allocator>' being compiled
C:\Boost\include\boost-1_62\boost/container/small_vector.hpp(484): warning C4346: 'boost::container::vector<T,boost::container::small_vector_allocator<Allocator>>::initial_capacity_t': dependent name is not a type
C:\Boost\include\boost-1_62\boost/container/small_vector.hpp(484): note: prefix with 'typename' to indicate a type
C:\Boost\include\boost-1_62\boost/container/small_vector.hpp(484): error C3646: 'initial_capacity_t': unknown override specifier
C:\Boost\include\boost-1_62\boost/container/small_vector.hpp(484): error C3254: 'boost::container::small_vector<T,N,Allocator>': class contains explicit override 'initial_capacity_t' but does not derive from an interface that contains the function declaration
C:\Boost\include\boost-1_62\boost/container/small_vector.hpp(484): error C2838: 'initial_capacity_t': illegal qualified name in member declaration
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\BuildCustomizations\CUDA 8.0.targets(687,9): error MSB3721: The command ""C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\bin\nvcc.exe" -gencode=arch=compute_52,code=\"sm_52,compute_52\" --use-local-env --cl-version 2015 -Xcompiler /FS -ccbin "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\x86_amd64"  -I.\GeneratedFiles -I. -IC:\Qt\5.8\msvc2015_64\include -I.\GeneratedFiles\Debug -IC:\Qt\5.8\msvc2015_64\include\QtCore -IC:\Qt\5.8\msvc2015_64\include\QtGui -IC:\Qt\5.8\msvc2015_64\include\QtOpenGL -IC:\Qt\5.8\msvc2015_64\include\QtWidgets -IC:\Qt\5.8\msvc2015_64\include\QtMultimedia -IC:\Qt\5.8\msvc2015_64\include\QtNetwork -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\include" -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\include" --source-in-ptx -G   --keep-dir x64\Debug -maxrregcount=0  --machine 64 --compile -cudart static --gpu-architecture=compute_30 --gpu-code=compute_30,sm_30,sm_35,sm_52,sm_61 -g  -use_fast_math -DUNICODE -DWIN32 -DWIN64 -DQT_DLL -DQT_CORE_LIB -DQT_GUI_LIB -DQT_OPENGL_LIB -DQT_WIDGETS_LIB -DQT_MULTIMEDIA_LIB -DQT_NETWORK_LIB -D_UNICODE -DUNICODE -D_AFXDLL -Xcompiler "/EHsc /W1 /nologo /Od /FS /Zi /RTC1 /MDd " -o x64\Debug\test.cu.obj "C:\fslim2\Slim5\test.cu"" exited with code 2.

Here is the version of small_vector.hpp I'm using http://pastebin.com/v3hh5r5q

Is Boost's small_vector compatible with NVCC?

Also screenshot of the failing line: enter image description here

Also tried Boost 1.63, still no dice.

Mikhail
  • 7,749
  • 11
  • 62
  • 136
  • 1
    NVCC is a compiler driver, which uses a "real" c++ compiler as back-end. It seems in your case it uses MSVC, so I'd say that it should just work. I also see no mention of any struct on line 484 of small_vector.hpp, so I'm not sure what's going on. Maybe [this question](http://stackoverflow.com/questions/8138673/why-does-nvcc-fails-to-compile-a-cuda-file-with-boostspirit?rq=1) hints that NVCC cannot handle template-heavy code very well. – rwols Feb 17 '17 at 22:23
  • I am not sure the 2011 question is relevant, the CUDA toolchain has changed a lot since then. The issue could be the pre-processing that `nvcc` applies to host code before passing it to the host compiler. The standard recommendation in cases like the one described by the OP is to move the problematic code out of the `.cu` file and into a `.cpp` file which is compiled directly by the host compiler (here: MSVC). – njuffa Feb 18 '17 at 00:30
  • @njuffa That is what I'm doing but I need want somebody to confirm (that would be the accepted answer). – Mikhail Feb 18 '17 at 01:37
  • Yo, this isn't a duplicate. That one has a different version of CUDA, and whatever black magic is used to work around my issue can very easily be different from the black magic in linked post. ITS NOT A DUPLICATE UNLESS ITS THE EXACT SAME BUG :-P – Mikhail Oct 27 '17 at 08:06

0 Answers0