I am trying to run a C++11 code on Unity Web GL. When I use source file in Assets/Plugins/WebGL folder; it compiled and run successfully. But if I have compiled code into llvm-bitcode using emcc and paste the resulted libray in Assets/Plugins/WebGL it gives the following error
Invalid function pointer called with signature 'vi'. Perhaps this is an invalid value (e.g. caused by calling a virtual method on a NULL pointer)? Or calling a function with an incorrect type, which will fail? (it is worth building your source files with -Werror (warnings are errors), as warnings can indicate undefined behavior which can cause this.
Here is my sample Code File "plugin.cpp":
class BaseTest; using BaseTestPtr = std::shared_ptr;
class BaseTest {
public:
virtual void printMe () = 0;
};
class DrivedTest;
using DrivedTestPtr = std::shared_ptr;
class DrivedTest : public BaseTest {
public:
static DrivedTestPtr create () {
DrivedTestPtr instance (new DrivedTest());
return instance;
}
void printMe () {
printf ("Hello Me");
}
};
extern "C" void printMe () {
BaseTestPtr ptr = DrivedTest::create();
ptr->printMe();
}
here is the c# bridge code
[DllImport("__Internal")] private static extern void printMe (); void Start () { printMe (); }
And I am generating llvm bitcode using command emcc -std=c++11 -emit-llvm -o plugin.bc plugin.cpp
Here is my sample Code File "plugin.cpp":
class BaseTest; using BaseTestPtr = std::shared_ptr
here is the c# bridge code
[DllImport("__Internal")] private static extern void printMe (); void Start () { printMe (); }
And I am generating llvm bitcode using command emcc -std=c++11 -emit-llvm -o plugin.bc plugin.cpp