Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice

Question error: expected unqualified-id IL2CPP_EXTERN_C void DEFAULT_CALL

Discussion in 'Web' started by cgbullock, Dec 14, 2023.

  1. cgbullock

    cgbullock

    Joined:
    Jul 11, 2023
    Posts:
    1
    Hello,

    I'm still relatively new to Unity and I'm trying to build and run a localhost Unity WebGL build that can receive values from a C++ DLL. I've run across several problems along the way that I have been able to find some form of documentation or help for. After getting through DLL dependency issues and EntryPointNotFound errors I finally reached a point where I got everything to load and run in the unity editor without problems. I thought this was a symbol of success and all I had to do was build and run through the build settings. Unfortunately I've run into one last wall. I receive this error stack when trying to build the WebGL build through the build settings tab.

    Unity Version: 2022.3.7f1

    Building Library\Bee\artifacts\WebGL\GameAssembly\release_WebGL_wasm\6o6ppuy09c00.o failed with output:
    C:\Users\CarterBullock\WebGL Test Project\Library\Bee\artifacts\WebGL\il2cppOutput\cpp\Assembly-CSharp.cpp:4368:35: error: expected unqualified-id
    IL2CPP_EXTERN_C void DEFAULT_CALL @ILT+7930(RegisterPlugin)();
    ^
    C:\Users\CarterBullock\WebGL Test Project\Library\Bee\artifacts\WebGL\il2cppOutput\cpp\Assembly-CSharp.cpp:4387:32: error: expected expression
    reinterpret_cast<PInvokeFunc>(@ILT+7930(RegisterPlugin))();
    ^
    C:\Users\CarterBullock\WebGL Test Project\Library\Bee\artifacts\WebGL\il2cppOutput\cpp\Assembly-CSharp.cpp:4387:32: error: expected ')'
    C:\Users\CarterBullock\WebGL Test Project\Library\Bee\artifacts\WebGL\il2cppOutput\cpp\Assembly-CSharp.cpp:4387:31: note: to match this '('
    reinterpret_cast<PInvokeFunc>(@ILT+7930(RegisterPlugin))();
    ^
    3 errors generated.
    emcc: error: '"C:/Program Files/Unity/Hub/Editor/2022.3.7f1/Editor/Data/PlaybackEngines/WebGLSupport/BuildTools/Emscripten/llvm\clang++.exe" -target wasm32-unknown-emscripten -DEMSCRIPTEN -D__EMSCRIPTEN_major__=3 -D__EMSCRIPTEN_minor__=1 -D__EMSCRIPTEN_tiny__=8 -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-cxx-exceptions -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr -Werror=implicit-function-declaration -Xclang -iwithsysroot/include/SDL "--sysroot=C:\Program Files\Unity\Hub\Editor\2022.3.7f1\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\Emscripten\emscripten\cache\sysroot" -Xclang -iwithsysroot/include\compat -D__webgl__ -Wno-c++11-extensions -Wno-nonportable-include-path -ffunction-sections -fno-unwind-tables -fomit-frame-pointer -fno-threadsafe-statics -std=c++11 -Wno-#warnings -Wswitch -Wno-trigraphs -Wno-tautological-compare -Wno-invalid-offsetof -Wno-implicitly-unsigned-literal -Wno-integer-overflow -Wno-shift-negative-value -Wno-unknown-attributes -Wno-implicit-function-declaration -Wno-null-conversion -Wno-missing-declarations -Wno-unused-value -Wno-pragma-once-outside-header -fvisibility=hidden -fexceptions -fno-rtti -O3 -fno-strict-overflow -ffunction-sections -fdata-sections -fmessage-length=0 -pipe -D_GLIBCXX_USE_CXX11_ABI=0 -DBASELIB_INLINE_NAMESPACE=il2cpp_baselib -DIL2CPP_MONO_DEBUGGER_DISABLED -DRUNTIME_IL2CPP -DHAVE_BDWGC_GC -DNDEBUG -I. "-IC:/Users/CarterBullock/WebGL Test Project/Library/Bee/artifacts/WebGL/il2cppOutput/cpp" "-IC:/Program Files/Unity/Hub/Editor/2022.3.7f1/Editor/Data/il2cpp/libil2cpp/pch" "-IC:/Program Files/Unity/Hub/Editor/2022.3.7f1/Editor/Data/il2cpp/libil2cpp" "-IC:/Program Files/Unity/Hub/Editor/2022.3.7f1/Editor/Data/il2cpp/external/baselib/Include" "-IC:/Program Files/Unity/Hub/Editor/2022.3.7f1/Editor/Data/il2cpp/libil2cpp/os/ClassLibraryPAL/brotli/include" "-IC:/Program Files/Unity/Hub/Editor/2022.3.7f1/Editor/Data/il2cpp/external/baselib/Platforms/WebGL/Include" -fcolor-diagnostics -fdiagnostics-absolute-paths -c -xc++ "C:/Users/CarterBullock/WebGL Test Project/Library/Bee/artifacts/WebGL/il2cppOutput/cpp/Assembly-CSharp.cpp" -o Library/Bee/artifacts/WebGL/GameAssembly/release_WebGL_wasm/6o6ppuy09c00.o' failed (returned 1)

    UnityEngine.GUIUtility:processEvent (int,intptr,bool&)


    It seems there is some issue with the conversion from C++ to C#? I'm not entirely sure what I did wrong to cause this and I haven't been able to find anything related to this error online. I have the extern "C" prefix before each function I'm trying to call, but I've also tried removing it with no luck on resolving the issue. Below is the code from the test project I'm trying to run. Any help or insight would be helpful and much appreciated!

    C# Unity Script:
    upload_2023-12-14_12-21-46.png

    C++ Header File:
    upload_2023-12-14_12-24-43.png

    C++ .cpp File:
    upload_2023-12-14_12-23-45.png

    NOTE:
    I've tried this same process without the RegisterPlugin function and any of the UNITY_WEBGL code and got the same error with testDLL(). I saw an article about how the UNITY_WEBGL code might be necessary to make the build work in WebGL but no luck. https://blog.unity.com/technology/low-level-plugins-in-unity-webgl