I have a C++ project, and I want to compile it to WASM and use it in js. This project will be compiled and get a cli used this way:
./CLI -m model_file_path -f format -output_dir ./
First step, I just compile this CMake project with:
emcmake cmake ..
And I get the CLI.js and CLI.wasm? run directly in Node:
node CLI.js -m model_file_path -f format -output_dir ./
It did get the same result with C++ Cli.
So I compile it again, but with modularize :
And I use it in JS, I first write the file selected in front end web to emscrpten virtual file system:
// uint8_arrs[0] are byte arrays converted from `inputModelFile.raw`, choosed by user.
module['FS'].writeFile('./original_model', uint8_arrs[0]);
And then I combine the args to args = ["-m", "./original_model", ...], call the main entrance:
module.callMain(args)
But I get weird error in catch:
try{
module.callMain(args)
}catch (e) {
console.log(e);
success = false;
ret = e;
}
Error:
What's the 5508328 mean? thanks.