TL;DR: libvlc can't be loaded in a build because its dependencies can't be loaded. But Dependency Walker shows a tree with hundreds of DLLs in it, so I don't think I should just copy them all into the project.
----------
I'm using HyperVLC, which is a C# wrapper for libvlc.dll, which is part of VLC media player.
The HyperVLC example includes the following function:
[DllImport("kernel32.dll", SetLastError = true)]
public static extern bool SetDllDirectory(string lpPathName);
In Awake, I call SetDllDirectory(@"C:\Program Files\VideoLAN\VLC"); which allows the Unity editor to find libvlc.dll without needing to put it in the project, but for some reason it doesn't work in a build (windows standalone), it just gives me "DllNotFoundException: libvlc".
I've also tried putting all the VLC DLLs in the project (next to Assets and in Assets/Plugins), but that doesn't work either.
Googling has led me to believe that the error actually means that the dependencies of libvlc.dll can't be loaded rather than the DLL itself. So I got [Dependency Walker](http://www.dependencywalker.com/) to take a look at it, which gave me the following tree:
- LIBVLC.DLL
- LIBVLCCORE.DLL
- ADVAPI.DLL
- About 20 more DLLs, some with more dependencies.
- KERNEL32.DLL
- NTDLL.DLL
- MSVCRT.DLL
- SHELL32.DLL
- About 100 more DLLs, some with more dependencies.
- USER32.DLL
- About 10 more DLLs, some with more dependencies.
- WINMM.DLL
- About 10 more DLLs, some with more dependencies.
- WS2_32.DLL
- About 20 more DLLs, some with more dependencies.
- KERNEL32.DLL
- About 40 more DLLs.
- MSVCRT.DLL
- About 40 more DLLs.
Most of those sound like Windows DLLs, so I don't understand how the editor can find them perfectly fine while a build can't. And if this is actually the problem, I don't understand why the editor wouldn't just copy all the required DLLs into the build when it already knows where they are.
How can I fix this problem?
↧