Hello, I am trying to tweak emscripten parameters used to compile ZXing C++ port that can be found here : https://github.com/nu-book/zxing-cpp/tree/master I would like to be able to use the generated file to import the library using webpack.
I am already using opencv.js with webpack and it works like a charm.
I have tweaked the CMakeLists.txt file of nu-book/zxing-cpp project and changed
the last line to this :
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --bind -Oz -s
DISABLE_EXCEPTION_CATCHING=0 -s FILESYSTEM=0 -s WASM=1 -s MODULARIZE=1 -s
SINGLE_FILE=1 -s EXPORT_NAME=\"'zxing'\"")
So basically, I request a self-contained .js file that embeds the wasm binary,
specify a custom export name and enable modularization.
In my javascript file, I import my file like this
import zxing from "zxing-js/zxing_reader.js";
where zxing_reader.js is the file generated by emscripten.
Next in my code, I call it like explained in demo_reader.html but with my new
export name (zxing)
var buffer = zxing._malloc(imageData.length);
zxing.HEAPU8.set(imageData.data, buffer);
var result = zxing.readBarcodeFromPng(imageData, imageData.length, true,
'QR_CODE');
zxing._free(buffer);
but when I try to execute, I get an error stating that _malloc is not a
function.
TypeError:
zxing_js_zxing_reader_js__WEBPACK_IMPORTED_MODULE_2___default.a._malloc is not
a function
I tried to search about this error and found out that functions should be added
in EXPORTED_FUNCTIONS, so I re-tried with
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --bind -Oz -s
DISABLE_EXCEPTION_CATCHING=0 -s FILESYSTEM=0 -s WASM=1 -s MODULARIZE=1 -s
SINGLE_FILE=1 -s EXPORTED_FUNCTIONS=\"['_malloc', '_free']\" -s
EXPORT_NAME=\"'zxing'\"")
but it still does not work (got the same error).
I also tried to change optimization level to other values and it does not work
even with `-O0`
I am really new to all this emscripten stuff so, if any of you have an idea, it
would be really helpful :)
Thanks :)
Jean
Ce message est signé pour en garantir l'authenticité.
Vous pouvez vérifier l'authenticité de ce message (et répondre de façon
sécurisée en chiffrant votre réponse) à l'aide de la clé publique attachée à ce
message.
--
You received this message because you are subscribed to the Google Groups
"emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.
publickey - [email protected] - 0x259843BA.asc
Description: application/pgp-keys
signature.asc
Description: OpenPGP digital signature
