Unity WebGL System.DllNotFoundException (libproc) Error Solution

Unity WebGL System.DllNotFoundException (libproc) Error Solution

Unity System.DllNotFoundException (libproc) Error Solution

 Hello everyone, on Mac OS 12.3 and later operating systems, while taking Unity WebGL output, I encountered the error below

System.DllNotFoundException: Unable to load shared library 'libproc' or one of its dependencies. In order to help diagnose loading problems, consider setting the DYLD_PRINT_LIBRARIES environment variable: dlopen(liblibproc, 0x0001): tried: 'liblibproc' (no such file), '/usr/local/lib/liblibproc' (no such file)

I discovered that this error is related to the new version of Mac OS, and after some research, I learned that this can be solved with a small script you add to your project.

Of course, before creating this script, you need to have Python installed on your computer, and you should not forget to change and adjust the code below according to the version of Python installed on your system.

Our Script

#if UNITY_EDITOR
using UnityEditor;
using UnityEditor.Build;
using UnityEditor.Build.Reporting;
using UnityEngine;
 
public class PreBuildProcessing : IPreprocessBuildWithReport
{
    public int callbackOrder => 1;
    public void OnPreprocessBuild(BuildReport report)
    {
        System.Environment.SetEnvironmentVariable("EMSDK_PYTHON", "/Library/Frameworks/Python.framework/Versions/3.10/bin/python3");
    }
}
#endif

If you have fulfilled all the conditions above and still get the error, Python EMSDK may not be installed; try installing Python EMSDK and try to get the output again. If you still continue to receive errors, you can ask me below as a comment.

Note: The above solution script is provided for Mac, but you can use it for the solution by changing it with the Python location found on Windows/Linux.

Solution Logic

If I would explain why the above solution works, the error actually occurs because Unity cannot find its own WebAssembly compiler, and with our solution here, we solve it by using the WebAssembly available in Python.