编译NvRTX焦散分支Unreal Engine后缺失dxgi.lib求助
I’ve run into nearly identical third-party library path issues when compiling custom UE branches before—those vague "unresolvable library" warnings almost always point to a broken path reference or missing files. Here are actionable steps to fix the dxgi.lib error:
1. Verify Third-Party DirectX Library Completeness
The NVIDIA branch might not include the full DirectX third-party files (common if submodules weren’t cloned properly, or the repo uses .gitignore to exclude large precompiled libs).
- First, check if the path
ThirdParty/Windows/DirectX/Lib/x64/actually exists in your cloned engine directory. If it’s missing or empty:- Re-clone the repo with submodule support using
git clone --recursive https://github.com/NvRTX/UnrealEngine/tree/NvRTX_Caustics - Or, copy the complete DirectX
Libfolder from a working Unreal Engine source build (official 4.x branch matching the NVIDIA branch’s base version) into the corresponding ThirdParty directory.
- Re-clone the repo with submodule support using
2. Fix Library Path References in the DX11 Module
The warning message hints that the DX11 module is using an unqualified path for dxgi.lib. Let’s update the build configuration:
- Navigate to
Engine/Source/Runtime/DX11/DX11.build.cs - Modify the library reference to use absolute paths via UE’s built-in directory variables:
// Replace any hardcoded relative paths with this string DirectXLibDir = Path.Combine(EngineDirectory, "ThirdParty", "Windows", "DirectX", "Lib", "x64"); PublicAdditionalLibraries.Add(Path.Combine(DirectXLibDir, "dxgi.lib")); - Alternatively, to suppress the warning and use system-style path searching, add the directory to
PublicSystemLibraryPaths:PublicSystemLibraryPaths.Add(Path.Combine(EngineDirectory, "ThirdParty", "Windows", "DirectX", "Lib", "x64")); // Then just reference the library name without the full path PublicAdditionalLibraries.Add("dxgi.lib");
3. Manually Add the Path to Visual Studio’s Linker Configuration
If the project generation script doesn’t pick up the path correctly, manually add it to your VS project:
- Open the UE4Editor solution in Visual Studio 2017
- Right-click the
DX11module project (under theRuntimefolder) → Properties - Go to Linker > General > Additional Library Directories
- Add the path
$(EngineDir)/ThirdParty/Windows/DirectX/Lib/x64and click OK
4. Clean and Regenerate Project Files
Cached build artifacts or outdated project files often cause these issues. Do a full clean:
- Delete the
Engine/BinariesandEngine/Intermediatefolders - Run
Engine/Build/BatchFiles/GenerateProjectFiles.batto regenerate the VS solution - Do a Clean Solution in Visual Studio, then rebuild the entire engine from scratch (skip incremental builds for this fix)
内容的提问来源于stack exchange,提问作者Bachalo

