emscripten icon indicating copy to clipboard operation
emscripten copied to clipboard

Since 1.37.24 lengthBytesUTF8 missing from available exported runtime methods

Open fhqvst opened this issue 8 years ago • 6 comments

First of all, thanks for building this great tool! It's been a pleasure to use so far.

Now, since version 1.37.24 a bunch of runtime methods are no longer exported by default. It seems that perhaps lengthBytesUTF8 was forgotten when defining the array of available exported runtime methods.

The resulting behaviour is that Module.lengthBytesUTF8 is undefined, even if specified in the EXTRA_EXPORTED_RUNTIME_METHODS.

I'm not at all experienced with the emscripten source code, but it seems a simple fix would be just to add lengthBytesUTF8 to that array. I can create a pull request if that's the case.

fhqvst avatar Jan 26 '18 10:01 fhqvst

Hello,

Module.lengthBytesUTF8() (as well as Module.stringToUTF8(), Module.Pointer_stringify(), ...) should be now available as global lengthBytesUTF8().

vedadkajtaz avatar Jan 26 '18 12:01 vedadkajtaz

Thanks for the speedy response! I've now exchanged all Module.<function> calls to just <function> and it seems to be working. All good!

fhqvst avatar Jan 26 '18 14:01 fhqvst

I'm having a similar problem when trying to access the code from outside:

cat index.js:
const lib = require('./Module')
lib.lengthBytesUTF8(...)

after

em++ lib.cc ... -o Module.js

mdobrogostsc avatar Jan 29 '18 22:01 mdobrogostsc

@mdobrogostsc you need to export things that you use from the outside, see https://kripken.github.io/emscripten-site/docs/getting_started/FAQ.html#why-do-i-get-typeerror-module-something-is-not-a-function

kripken avatar Jan 29 '18 23:01 kripken

Thanks @kripken. I get: warning: invalid item (maybe a typo?) in EXPORTED_RUNTIME_METHODS: lengthBytesUTF8.

mdobrogostsc avatar Jan 30 '18 16:01 mdobrogostsc

Thanks @mdobrogostsc , that function was missing from the list of possible exports. Fix in #6159.

kripken avatar Jan 30 '18 20:01 kripken