WebGL build error (unity2021.3.6)
Hi, I used websoket.I can't build a webgl program in unity2021.3.6, it reports an error. There is no such error in unity2020.
Building Library\Bee\artifacts\WebGL\build\debug_WebGL_wasm\build.js failed with output:
error: undefined symbol: sendfile (referenced by top-level compiled C/C++ code)
warning: Link with -s LLD_REPORT_UNDEFINED to get more information on undefined symbols
warning: To disable errors for undefined symbols use -s ERROR_ON_UNDEFINED_SYMBOLS=0
warning: _sendfile may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
https://forum.unity.com/threads/webgl-build-error-unity2021-3-6.1320369/
Hi @z79422957. I also faced this issue in unity 2021.3.8. Did you resolve it?
Emscripten doesn't support sendfile and I don't think we ever even had a stub for it. There used to be a header which was removed in #14248.
Can you try adding -Wl,--trace-symbol=sendfile to your link command?
@juj maybe be able to help on the unity side.
@sidorovkirill @z79422957 are you saying that the same Unity project used to build successfully over to WebGL with Unity 2020.something.something, but after updating to Unity 2021.3.8, it no longer does, but gives the error about the sendfile function?
If that is the case, then this does sound like a potential Unity regression - feel free to report it if you have a small uploadable repro.
The function sendfile indeed should not exist in Emscripten or in Unity, and Unity code should not be depending on it, which makes me curious where that could come from.
If you want to test the issue out yourself, you could create a Unity editor script under <YourUnityProject>/Assets/Editor/MyWebGLEditorScript.cs, with the contents
using UnityEditor;
public class Foo
{
Foo()
{
PlayerSettings.WebGL.emscriptenArgs = "-Wl,--trace-symbol=sendfile";
}
}
That will issue an extra linker directive to Emscripten at WebGL build link time. You'll likely need to read the results out of the log file C:\Users<username>\AppData\Local\Unity\Editor\Editor.log
When I run that locally on an empty Unity project, I don't find any logs being printed, which means that LLVM linker thinks that function is not present or referenced (like it shouldn't be).
I had foud what happend with Bee issue :D That's because if you use any package or API script incloude [DllImport("__Internal")],you need to have same name .jslib file you called, the file icon in Unity just like a piece of puzzle
I had the same issue, then i cheked my link.xml file and remove below files in [System] assembly "System.Net.Sockets.NetworkStream" "System.Net.Sockets.Socket" "System.Net.Sockets.SocketException" "System.Net.Sockets.TcpClient" p "System.Net.Sockets.TcpListener"