why emscripten cannot export c++ functions using -O2 ?
compile following codes by emcc , then called with console.log('lerp result: ' + Module.lerp(1, 2, 0.5));
if add -O2 to the compile options , the browser throw exception : Uncaught TypeError: Module.lerp is not a function, if change -O2 to -O1 ,all goes well .
does somebody known how to export c++ functions by EMSCRIPTEN_BINDINGS with -O2 flag ? as -O1 output too large size of .js file. thanks in advance .
include
include <malloc.h>
include <emscripten/bind.h>
using namespace emscripten;
float lerp(float a, float b, float t) { return (1 - t) * a + t * b; }
EMSCRIPTEN_BINDINGS(my_module) { function("lerp", &lerp); }
Hi, You may want to take a look at #3521 , I think you have the same problem.
#5537 seems to report similar behaviour
Looks like a duplicate of the other issues, closing.