ComputeCpp 2.1 doesn't compile with Visual Studio 2019 v16.7.2

Neither the template sample project in visual studio nor any project in the github examples compiles. The error messages mainly indicate there are some errors in the “tuple” and “utility” headers. I tried the C++ standard to default, 14 and 17, none works. Here is the error message compiling the template project:

1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.27.29110\include\utility(137,9): error : expected member name or ';' after declaration specifiers
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.27.29110\include\utility(137,9): error : expected ')'
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.27.29110\include\utility(218,24): error : expected member name or ';' after declaration specifiers
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.27.29110\include\utility(218,24): error : expected ')'
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.27.29110\include\xutility(63,31): error : '_To' does not refer to a value
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.27.29110\include\tuple(273,9): error : expected member name or ';' after declaration specifiers
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.27.29110\include\tuple(273,9): error : expected ')'
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.27.29110\include\tuple(351,5): error : non-static data member cannot be constexpr; did you intend to make it const?
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.27.29110\include\tuple(351,24): error : member '_Tuple_conditional_explicit_v' declared as a template
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.27.29110\include\tuple(351,79): error : expected ';' at end of declaration list
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.27.29110\include\tuple(974,19): error : out-of-line definition of 'pair<_Ty1, _Ty2>' does not match any declaration in 'pair<_Ty1, _Ty2>'
1>C:\Program Files\Codeplay\ComputeCpp\include\SYCL/kernel.h(320,10): error : no matching constructor for initialization of 'std::pair<const void *, size_t>' (aka 'pair<const void *, unsigned long long>')
1>C:\Program Files\Codeplay\ComputeCpp\include\SYCL/kernel.h(324,10): error : no matching constructor for initialization of 'std::pair<const void *, size_t>' (aka 'pair<const void *, unsigned long long>')
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\BuildCustomizations\ComputeCpp.targets(60,9): error MSB3721: The command ""C:\Program Files\Codeplay\ComputeCpp\bin\compute++.exe" -D_SIZE_T_DEFINED -D_ALLOW_COMPILER_AND_STL_VERSION_MISMATCH -Wno-ignored-attributes -fdiagnostics-format=msvc -sycl -O2 -nobuiltininc -I"C:\Program Files\Codeplay\ComputeCpp\include" -I"C:\Program Files\Codeplay\ComputeCpp\include\image_library" -I"C:\Users\Peter\source\repos\ComputeCpp SYCL\ComputeCpp SYCL\\" -o"C:\Users\Peter\source\repos\ComputeCpp SYCL\ComputeCpp SYCL\main.sycl" -c main.cpp " exited with code 1.
1>Done building project "ComputeCpp SYCL.vcxproj" -- FAILED.

In this thread
The workaround works, but please also provides a solution to normal visual studio projects.

Hi @szpeter, I just tried the template project using the ComputeCpp from the developer website and the template is building just fine.

Would you be able to post the entire build log that you are getting?

Thanks for replying. The template has a serious problem of using Windows 8.1 SDK by default, which won’t build on Windows 10 at all. After retarget to windows 10 sdk, that code block in my question is the entire build log

Hi @szpeter, thanks for pointing out the Windows 8.1 SDK. I agree that this is a problem. When I switched to the Windows 10 SDK I got the same log as you, so now I can reproduce the issue. I will raise the issue internally so we can take a proper look into it.

In the meantime, if the Visual Studio Solution based project is not working for you, I suggest a CMake based solution, like the one we have in the computecpp-sdk.

Hi again @szpeter. After further investigation I narrowed the issue down do the MSVC Toolset Version. In summary, v14.26 still works but v14.27 doesn’t and we are going to investigate this internally. So the SDK version can be the latest Windows 10 version you have, but you need to make sure that the MSVC Toolset Version is set to v14.26. You can do this in the Properties of your Project, like in the following image:

Since this was a very recent update from Microsoft, I didn’t notice it until today when I tried to build something after the update.

Hopefully you can keep working with a solution based project on Windows and thanks for the report.

2 Likes

Thank you very much. That solves the problem and is the best solution for now.
However I managed to figure out that on visual studio solution project, the workaround can be applied too. Go to project properties -> ComputeCpp SYCL Cpp -> Device -> Additional Options, add -D_ALLOW_COMPILER_AND_STL_VERSION_MISMATCH also works.
And if you are targeting nvidia ptx, add -sycl-target ptx64 to it.

Yes, this is a known issue. Basically, to use clang with the Windows SDK you need a specific version. MSVC 19.27 requires clang 10. Our compiler is based on clang 8 and _ALLOW_COMPILER_AND_STL_VERSION_MISMATCH is required to use the device on Windows, so the template automatically adds this flag for you.

Could you confirm which toolset are you using? I am looking for the number in that I mentioned in the previous post.

The problematic toolset I asked about in the question was 14.27.29110. Also the windows 10 sdk is labeled “latest”, don’t know what it means but there is a option to choose 18362. You should be able to confirm it using the latest stable version of visual studio.

Sorry for the long delay in answering this. A fix for this issue was found. In the meantime, if you want to use MSVC 14.27 you can add -D__CUDACC__ to the list of definitions. This will relax the restrictions imposed by the MSVC headers and compute++ will be able to compile the code.

1 Like