Fix hdCycles DLL init failure in install: exclude bundled CRTs, add python311.dll

Two independent fixes for the install layout:

1. Cycles bundles old MSVC CRT DLLs (MSVCP140 v14.34, VCRUNTIME140 v14.34)
   that are placed in install/bin/ via the CYCLES_INSTALL_DIR copy. These take
   precedence over System32 on the DLL search path. sycl8.dll (built with newer
   VS2022 CRT v14.42) calls functions that don't exist in the old version, causing
   ERROR_DLL_INIT_FAILED (1114) when hdCycles.dll loads embree4 -> sycl8. Fix:
   exclude MSVCP140*.dll, VCRUNTIME140*.dll, ucrtbase*.dll, api-ms-win-*.dll from
   the install(DIRECTORY cycles_install/) rule. The system VC++ Redistributable
   satisfies these at runtime.

2. usd_python.dll (the OpenUSD Python bindings DLL) was compiled against Python
   3.11 while our build targets Python 3.12. Add auto-detection of python311.dll
   from common install paths and deploy it to both the build output and install/bin/
   so the dependency chain hdCycles->usd_python->python311 is satisfied.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-25 09:07:38 +08:00
parent e85944ccb6
commit 4b7323c24c
2 changed files with 51 additions and 5 deletions
+48 -3
View File
@@ -420,9 +420,21 @@ if(OPENUSD_HAS_CYCLES)
# Cycles runtime deps (embree4, epoxy, imath, openvdb, OIDN, sycl, etc.).
# No OPTIONAL: install(DIRECTORY) disallows it with FILES_MATCHING, and the
# dir always exists here since it is produced by the CyclesBuild step.
#
# EXCLUDE the MSVC CRT and api-ms-win DLLs that Cycles bundles: they are
# older than what the system ships (v14.34 vs system v14.42+), and placing
# an older MSVCP140.dll/VCRUNTIME140.dll ahead of System32 on the DLL
# search path causes sycl8.dll (built with newer CRT) to fail DllMain with
# ERROR_DLL_INIT_FAILED (1114) when hdCycles.dll is loaded.
# The system VC++ Redistributable always satisfies these deps at runtime.
install(DIRECTORY "${CYCLES_INSTALL_DIR}/"
DESTINATION bin
FILES_MATCHING PATTERN "*.dll"
FILES_MATCHING
PATTERN "*.dll"
PATTERN "MSVCP140*.dll" EXCLUDE
PATTERN "VCRUNTIME140*.dll" EXCLUDE
PATTERN "ucrtbase*.dll" EXCLUDE
PATTERN "api-ms-win-*.dll" EXCLUDE
)
# tbb12.dll (used by openvdb/embree4) lives in the precompiled lib tree, not install output
install(FILES "${CYCLES_TBB12_DLL}"
@@ -431,15 +443,48 @@ if(OPENUSD_HAS_CYCLES)
)
endif()
# Install Python runtime DLLs required by OpenUSD.
install(FILES
# Install Python runtime DLLs required by OpenUSD and Cycles.
# python312.dll : linked by Cycles (hdCycles.dll → python312.dll)
# python311.dll : linked by usd_python.dll (the OpenUSD Python bindings were
# built against Python 3.11, regardless of what we compile with)
# Detect python311.dll from common install paths.
foreach(_pyroot
"$ENV{LOCALAPPDATA}/Programs/Python/Python311"
"C:/Python311"
"C:/Program Files/Python311"
)
if(EXISTS "${_pyroot}/python311.dll")
set(PYTHON311_DLL "${_pyroot}/python311.dll")
message(STATUS "Found python311.dll (required by usd_python.dll): ${PYTHON311_DLL}")
break()
endif()
endforeach()
set(_python_runtime_dlls
"$ENV{LOCALAPPDATA}/Programs/Python/Python312/python312.dll"
"$ENV{LOCALAPPDATA}/Programs/Python/Python312/python3.dll"
)
if(PYTHON311_DLL)
list(APPEND _python_runtime_dlls "${PYTHON311_DLL}")
endif()
install(FILES ${_python_runtime_dlls}
DESTINATION bin
OPTIONAL # OPTIONAL so the install doesn't fail on machines with a
# system-wide Python; in that case the DLL is on PATH already.
)
# Also copy python311.dll to the build output directory so debug runs work
# without requiring C:\Python311 to be on PATH.
if(PYTHON311_DLL)
add_custom_command(TARGET UsdLayerManager POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
"${PYTHON311_DLL}"
"$<TARGET_FILE_DIR:UsdLayerManager>/python311.dll"
COMMENT "Copying python311.dll (for usd_python.dll)..."
)
endif()
# Copy resources to build directory
file(COPY ${CMAKE_SOURCE_DIR}/resources
DESTINATION ${CMAKE_BINARY_DIR}
+3 -2
View File
@@ -13,7 +13,7 @@
"IMGUI_DIR": "${sourceDir}/third_party/imgui-1.92.7",
"CMAKE_CXX_STANDARD": "17",
"CMAKE_CXX_STANDARD_REQUIRED": "ON",
"BUILD_TESTS": "ON",
"BUILD_TESTS": "OFF",
"WITH_CYCLES": "ON",
"HDARNOLD_ROOT": "E:/library/hdArnold",
"ARNOLD_LOCATION": "C:/Autodesk/mtoa/5.5.0/2026",
@@ -68,7 +68,8 @@
"name": "release",
"displayName": "Release Build",
"configurePreset": "release",
"configuration": "Release"
"configuration": "Release",
"targets": ["install"]
},
{
"name": "no-tests",