Delayed DLLs are not delayed during module loading

@epic please add UE 4.27 to the Product version list. The issue is related to 4.27

I have read several posts as well as code examples such as this one. in order to understand how to link
a plugin module with third party DLLs. In my case I am integrating some of the FFMPEG libraries into a plugin.

I put the DLLs in “ThirdParty/ffmpeg/bin” directory whereas “ThirdParty” is located at the same directory where resides Build.cs file.
Here is the part where I set up all the dependencies for ffmpeg libs:

            PrivateIncludePaths.Add(Path.Combine(ModuleDirectory, "ThirdParty/ffmpeg/include"));
	 
	// Add any import libraries or static libraries
	PublicAdditionalLibraries.Add(Path.Combine(ModuleDirectory, "ThirdParty/ffmpeg/lib", "avcodec.lib"));
	PublicAdditionalLibraries.Add(Path.Combine(ModuleDirectory, "ThirdParty/ffmpeg/lib", "avformat.lib"));
	PublicAdditionalLibraries.Add(Path.Combine(ModuleDirectory, "ThirdParty/ffmpeg/lib", "avutil.lib"));
	PublicAdditionalLibraries.Add(Path.Combine(ModuleDirectory, "ThirdParty/ffmpeg/lib", "swscale.lib"));

	PublicLibraryPaths.Add(Path.Combine(ModuleDirectory, "ThirdParty/ffmpeg/bin"));
	PublicDelayLoadDLLs.Add("avcodec-58.dll");
	PublicDelayLoadDLLs.Add("avformat-58.dll");
	PublicDelayLoadDLLs.Add("avutil-56.dll");
	PublicDelayLoadDLLs.Add("swscale-5.dll");
	PublicDelayLoadDLLs.Add("swresample-3.dll");

	string BaseDirectory = Path.GetFullPath(Path.Combine(ModuleDirectory, "..", ".."));
	string FFMPEGBinDirectory = Path.Combine(BaseDirectory, "ThirdParty", "ffmpeg", "bin");

	RuntimeDependencies.Add(Path.Combine(FFMPEGBinDirectory, "avcodec-58.dll"));
	RuntimeDependencies.Add(Path.Combine(FFMPEGBinDirectory, "avformat-58.dll"));
	RuntimeDependencies.Add(Path.Combine(FFMPEGBinDirectory, "avutil-56.dll"));
	RuntimeDependencies.Add(Path.Combine(FFMPEGBinDirectory, "swscale-5.dll"));
	RuntimeDependencies.Add(Path.Combine(FFMPEGBinDirectory, "swresample-3.dll"));

The problem is, those dlls are still not getting delayed. Once I am launching the project the engine spits a notification that it hasn’t been able to located those .dlls, which is makes sense as I didn’t deploy those files into Binary folder.That’s the whole point of using PublicDelayLoadDLLs, isn’t it?
Can anyone explain what I am missing here? Again, the goal is to load the DLLs. manually in runtime during my plugin module startup.
Thanks.

1 Like

same question

如果你是从https://github.com/BtbN/FFmpeg-Builds下载的ffmpeg,
你需要重新生成xxx.lib文件, 交叉编译产生的xxx.lib文件有点问题
打开你的vs2019->工具->命令行,进入到下载的ffmpeg-xxxx-gpl-shared/lib/
然后执行以下命令
lib.exe /def:avcodec-59.def /machine:x64 /out:avcodec.lib
lib.exe /def:avdevice-59.def /machine:x64 /out:avdevice.lib
lib.exe /def:avfilter-8.def /machine:x64 /out:avfilter.lib
lib.exe /def:avformat-59.def /machine:x64 /out:avformat.lib
lib.exe /def:avutil-57.def /machine:x64 /out:avutil.lib
lib.exe /def:postproc-56.def /machine:x64 /out:postproc.lib
lib.exe /def:swresample-4.def /machine:x64 /out:swresample.lib
lib.exe /def:swscale-6.def /machine:x64 /out:swscale.lib
然后使用最新的xxx.lib文件就可以了

1 Like