Libtorch dll not found when scanning plugin

Hello everyone,

As a university project, I’m developing an open source drum-demixing VST3 plugin using LibTorch and the Juce framework. Here’s the issue I’m facing:

In my CMake setup, I copy all of LibTorch’s DLLs into the same folder as both the VST3 plugin and the standalone executable. The standalone version loads and runs correctly, but the VST3 does not—Windows simply can’t find the DLLs when the host loads the plugin. I even opened the VST3 in Dependencies.exe and saw no missing-import errors; all required symbols appear resolved, yet the plugin still fails to load.

I discovered this is due to Windows’ DLL search order: for an .exe, Windows checks the executable’s folder first, but for a .dll loaded by another process it doesn’t. I tried using MSVC’s /DELAYLOAD option so the DLLs would load on first use, but one of the DLLs (the one exporting at::indexing::Ellipsis) exposes a global data symbol, which MSVC cannot delay-load (delay-load only works for functions). The linker even tells me directly: “Do not delay-load this DLL.”

The interesting thing is that the problem does not happen when I load the VST3 it in the AudioPluginHost.exe (the Juce plugin host), but in every DAW it does not load. If then I add the LibTorch-DLL directory to my system PATH, the VST3 plugin works also in all DAWs—Windows finds the DLLs there—but modifying the global PATH isn’t a practical distribution solution.

Do you know a better way to ensure Windows will load those DLLs alongside my .vst3? For example, would building LibTorch as static libraries and linking them into the plugin be a viable approach? Any guidance or alternative suggestions would be greatly appreciated—this problem has me stumped!

Thanks in advance for your help!