emscripten icon indicating copy to clipboard operation
emscripten copied to clipboard

why emscripten cannot export c++ functions using -O2 ?

Open fulean opened this issue 11 years ago • 3 comments

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); }

fulean avatar Jun 16 '15 07:06 fulean

Hi, You may want to take a look at #3521 , I think you have the same problem.

AlexPerrot avatar Jun 16 '15 14:06 AlexPerrot

#5537 seems to report similar behaviour

bzz avatar Apr 02 '18 15:04 bzz

Looks like a duplicate of the other issues, closing.

kripken avatar Apr 02 '18 18:04 kripken