I've been compiling a single C++ function into wasm for a while now on a windows environment. The function lives in a c++ file named "project.cpp" and the functions name is "project".
Below are my command line arguments:
emcc project.cpp -s WASM=1 -s EXPORTED_FUNCTIONS="['_project']" -s EXTRA_EXPORTED_RUNTIME_METHODS='["ccall", "cwrap"]' -o ../index.js
For several weeks this has been working great. However I just updated to the latest version of emscripten (don't remember which version I was using before) and now I get this error:
Error:root:cwrap]': No such file or directory ("cwrap]'" was expected to be an input file based on the command arguments provided).
In response I tried to compile it by seperating the "ccall" and "cwrap" mehtods into their own command like arguments:
-s EXTRA_EXPORTED_RUNTIME_METHODS='["cwrap"]' -s EXTRA_EXPORTED_RUNTIME_METHODS='["ccall"]'
And that just made my screen light up with errors.
So I tried to only do:
-s EXTRA_EXPORTED_RUNTIME_METHODS='["ccall"]'
That worked, as in it successfully built from the command line, however when I load the program in the browser I get this error:
Module.ccall is not a function
Has the latest update changed things? I can't not find anything in the documentation.
Edit ---------------------------------------------------------------
I just tried compiling the same c++ file on Linux using the same command line parameters I mentioned above and it worked. I am using 1.37.27 on Linux which to my understanding is the latest version (though I fear updating to verify that because I don't want to break my linux like I broke my windows).
Any help would be greatly appreciated!
This seems like a quoting issue, which was recently given some docs on the FAQ,
https://kripken.github.io/emscripten-site/docs/getting_started/FAQ.html#why-do-i-get-a-nameerror-or-a-problem-occurred-in-evaluating-content-after-a-s-when-i-use-a-s-option
However, it's very strange this worked before but fails later, since we didn't change anything there - this would have been always the case, assuming the OS and shell are the same. So maybe this is something other than quoting? But I would try the suggestion in that new faq entry, to quote like this:
-s "EXTRA_EXPORTED_RUNTIME_METHODS=['ccall', 'cwrap']"
Following the example steps for compiling and using WASM (https://developer.mozilla.org/en-US/docs/WebAssembly/C_to_wasm) on Windows 10 (VS15/Python2.7 via npm install windows-build-tools) I found that I have to call the compiler like this to get it to work.
emcc -o hello.html hello.c -O3 -s WASM=1 --shell-file shell_minimal.html -s NO_EXIT_RUNTIME=1 -s "EXTRA_EXPORTED_RUNTIME_METHODS=['ccall']"
version details
emcc -v
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 1.37.36
clang version 5.0.0 (https://github.com/kripken/emscripten-fastcomp-clang.git c8606950a97dea79eb578599bb13a48a1639661a) (https://github.com/kripken/emscripten-fastcomp.git 0d8129bb20f502b9ba26d54414f05120f5622b4b) (emscripten 1.37.36 : 1.37.36)
Target: x86_64-pc-windows-msvc
Thread model: posix
InstalledDir: C:\development\c\emsdk\clang\fastcomp\build_incoming_vs2015_64\Release\bin
It works! Thanks.
This issue has been automatically marked as stale because there has been no activity in the past year. It will be closed automatically if no further activity occurs in the next 7 days. Feel free to re-open at any time if this issue is still relevant.
Most helpful comment
This seems like a quoting issue, which was recently given some docs on the FAQ,
https://kripken.github.io/emscripten-site/docs/getting_started/FAQ.html#why-do-i-get-a-nameerror-or-a-problem-occurred-in-evaluating-content-after-a-s-when-i-use-a-s-option
However, it's very strange this worked before but fails later, since we didn't change anything there - this would have been always the case, assuming the OS and shell are the same. So maybe this is something other than quoting? But I would try the suggestion in that new faq entry, to quote like this: