Error message when building Blender with CUDA and OptiX GPU Binaries

When building Blender with CUDA Toolkit 11 and OptiX SDK 7.5 I get the following error message:

Building Custom Rule C:/v4blender/blender/source/creator/CMakeLists.txt tracks.cc buildinfo.c buildinfoobj.vcxproj -> C:\v4blender\build_windows_Release_x64_vc17_Release\source\creator\buildinfoobj.dir\Release\b uildinfoobj.lib 
Generating cycles_kernel_oneapi.dll LINK : fatal error LNK1104: cannot open file 'msvcrt.lib' 
C:\v4blender\build_windows_Release_x64_vc17_Release\intern\c ycles\kernel\cycles_kernel_oneapi.vcxproj] clang++ : 
error : linker command failed with exit code 1104 (use -v to see invocation) 
C:\v4blender\build_windows_Rele ase_x64_vc17_Release\intern\cycles\kernel\cycles_kernel_oneapi.vcxproj] C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(247,5): e rror MSB8066: 
Custom build for 
'C:\v4blender\build_windows_Release_x64_vc17_Release\CMakeFiles\9a079923408350e0956debdf 9ed82598\cycles_kernel_oneapi.dll.rule;C:\v4blender\build_windows_Release_x64_vc17_Release\CMakeFiles\fe12296c4cd2c7c17 7e132d7619626ed\cycles_kernel_oneapi.rule;C:\v4blender\blender\intern\cycles\kernel\CMakeLists.txt' 
exited with code 11 04. [C:\v4blender\build_windows_Release_x64_vc17_Release\intern\cycles\kernel\cycles_kernel_oneapi.vcxproj]

It then proceeds to compile other files until it stops with

Error during build, see C:\v4blender\blender..\build_windows_Release_x64_vc17_Release\Build.log for details

Opening Build.log shows a bunch of files that were compiled and at the end of the file it says:

Build FAILED.

C:/v4blender/blender/../lib/win64_vc15/openvdb/include\nanovdb/NanoVDB.h(623): warning #68-D: integer conversion resulted in a change of sign 
C:\v4blender\build_windows_Release_x64_vc17_Release\intern\cycles\kernel\cycles_kernel_cuda.vcxproj] C:/v4blender/blender/../lib/win64_vc15/openvdb/include\nanovdb/NanoVDB.h(623): warning #68-D: integer conversion resulted in a change of sign 
C:\v4blender\build_windows_Release_x64_vc17_Release\intern\cycles\kernel\cycles_kernel_optix.vcxproj] C:/v4blender/blender/../lib/win64_vc15/openvdb/include\nanovdb/NanoVDB.h(623): warning #68-D: integer conversion resulted in a change of sign 
C:\v4blender\build_windows_Release_x64_vc17_Release\intern\cycles\kernel\cycles_kernel_optix.vcxproj] C:/v4blender/blender/../lib/win64_vc15/openvdb/include\nanovdb/NanoVDB.h(623): warning #68-D: integer conversion resulted in a change of sign 
C:\v4blender\build_windows_Release_x64_vc17_Release\intern\cycles\kernel\cycles_kernel_cuda.vcxproj] C:/v4blender/blender/../lib/win64_vc15/openvdb/include\nanovdb/NanoVDB.h(623): warning #68-D: integer conversion resulted in a change of sign 
C:\v4blender\build_windows_Release_x64_vc17_Release\intern\cycles\kernel\cycles_kernel_cuda.vcxproj] C:/v4blender/blender/../lib/win64_vc15/openvdb/include\nanovdb/NanoVDB.h(623): warning #68-D: integer conversion resulted in a change of sign 
C:\v4blender\build_windows_Release_x64_vc17_Release\intern\cycles\kernel\cycles_kernel_cuda.vcxproj] C:/v4blender/blender/../lib/win64_vc15/openvdb/include\nanovdb/NanoVDB.h(623): warning #68-D: integer conversion resulted in a change of sign 
C:\v4blender\build_windows_Release_x64_vc17_Release\intern\cycles\kernel\cycles_kernel_cuda.vcxproj] C:/v4blender/blender/../lib/win64_vc15/openvdb/include\nanovdb/NanoVDB.h(623): warning #68-D: integer conversion resulted in a change of sign C:\v4blender\build_windows_Release_x64_vc17_Release\intern\cycles\kernel\cycles_kernel_cuda.vcxproj] C:/v4blender/blender/../lib/win64_vc15/openvdb/include\nanovdb/NanoVDB.h(623): warning #68-D: integer conversion resulted in a change of sign 
C:\v4blender\build_windows_Release_x64_vc17_Release\intern\cycles\kernel\cycles_kernel_cuda.vcxproj] C:/v4blender/blender/../lib/win64_vc15/openvdb/include\nanovdb/NanoVDB.h(623): warning #68-D: integer conversion resulted in a change of sign 
C:\v4blender\build_windows_Release_x64_vc17_Release\intern\cycles\kernel\cycles_kernel_cuda.vcxproj] C:/v4blender/blender/../lib/win64_vc15/openvdb/include\nanovdb/NanoVDB.h(623): warning #68-D: integer conversion resulted in a change of sign 
C:\v4blender\build_windows_Release_x64_vc17_Release\intern\cycles\kernel\cycles_kernel_cuda.vcxproj] C:/v4blender/blender/../lib/win64_vc15/openvdb/include\nanovdb/NanoVDB.h(623): warning #68-D: integer conversion resulted in a change of sign 
C:\v4blender\build_windows_Release_x64_vc17_Release\intern\cycles\kernel\cycles_kernel_cuda.vcxproj] C:\v4blender\lib\win64_vc15\tbb\include\tbb/parallel_sort.h(125,1): warning C4180: qualifier applied to function type has no meaning; ignored 
C:\v4blender\build_windows_Release_x64_vc17_Release\source\blender\gpencil_modifiers\bf_gpencil_modifiers.vcxproj] C:\v4blender\lib\win64_vc15\tbb\include\tbb/parallel_sort.h(128): warning C4180: qualifier applied to function type has no meaning; ignored 
C:\v4blender\build_windows_Release_x64_vc17_Release\source\blender\gpencil_modifiers\bf_gpencil_modifiers.vcxproj] C:\v4blender\lib\win64_vc15\tbb\include\tbb/parallel_sort.h(128,1): warning C4180: qualifier applied to function type has no meaning; ignored 
C:\v4blender\build_windows_Release_x64_vc17_Release\source\blender\gpencil_modifiers\bf_gpencil_modifiers.vcxproj] C:\v4blender\lib\win64_vc15\tbb\include\tbb/parallel_sort.h(102,1): warning C4180: qualifier applied to function type has no meaning; ignored 
C:\v4blender\build_windows_Release_x64_vc17_Release\source\blender\gpencil_modifiers\bf_gpencil_modifiers.vcxproj] C:\v4blender\lib\win64_vc15\tbb\include\tbb/parallel_sort.h(106): warning C4180: qualifier applied to function type has no meaning; ignored 
C:\v4blender\build_windows_Release_x64_vc17_Release\source\blender\gpencil_modifiers\bf_gpencil_modifiers.vcxproj] C:\v4blender\lib\win64_vc15\tbb\include\tbb/parallel_sort.h(106,1): warning C4180: qualifier applied to function type has no meaning; ignored 
C:\v4blender\build_windows_Release_x64_vc17_Release\source\blender\gpencil_modifiers\bf_gpencil_modifiers.vcxproj] LINK : fatal error LNK1104: cannot open file 'msvcrt.lib' 
C:\v4blender\build_windows_Release_x64_vc17_Release\intern\cycles\kernel\cycles_kernel_oneapi.vcxproj] clang++ : error : linker command failed with exit code 1104 (use -v to see invocation) 
C:\v4blender\build_windows_Release_x64_vc17_Release\intern\cycles\kernel\cycles_kernel_oneapi.vcxproj] C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(247,5): error MSB8066: Custom build for 'C:\v4blender\build_windows_Release_x64_vc17_Release\CMakeFiles\9a079923408350e0956debdf9ed82598\cycles_kernel_oneapi.dll.rule;C:\v4blender\build_windows_Release_x64_vc17_Release\CMakeFiles\fe12296c4cd2c7c177e132d7619626ed\cycles_kernel_oneapi.rule;C:\v4blender\blender\intern\cycles\kernel\CMakeLists.txt' exited with code 1104. 
C:\v4blender\build_windows_Release_x64_vc17_Release\intern\cycles\kernel\cycles_kernel_oneapi.vcxproj] 18 Warning(s) 3 Error(s)

Time Elapsed 00:45:48.68

How can I fix the error?

All the error messages appear to be related to oneAPI. Try opening the cmake file and disabling the oneAPI Cycles backend.

What exactly do I have to do to disable the oneAPI Cycles backend? I am new to building Blender.

Thanks!

Open up the cmake file for your build, search for oneAPI, and disable it.

For example, open up the command prompt, and type in
cmake-gui C:\v4blender\build_windows_Release_x64_vc17_Release\CMakeCache.txt
and this will open up a application.
In the search box, search for oneAPI and disable WITH_CYCLES_DEVICE_ONEAPI and WITH_CYCLES_ONEAPI_BINARIES
After you’ve done that, select Generate at the bottom right of cmake-gui, wait for it to finish, then try and build Blender again.

It worked!

Although I only changed WITH_CYCLES_DEVICE_ONEAPI=ON to WITH_CYCLES_DEVICE_ONEAPI=OFF, as I couldn’t find the WITH_CYCLES_ONEAPI_BINARIES setting.

Is there another CMake file other than CMakeCache.txt?