run emrun with args from int main(int argc, char* argv[])

18 views
Skip to first unread message

Balázs Varga

unread,
Dec 5, 2022, 6:30:08 AM12/5/22
to emscripten-discuss
Hi All,

Is it possible somehow to run a wasm app from another wasm app? For example, running the emrun command from a main cpp function, somehow?

int main(int argc, char* argv[])
{
     emrun --serve_after_close foo.html;
}

Thanks for your help, in advance.
Balázs

Sam Clegg

unread,
Dec 5, 2022, 6:33:04 PM12/5/22
to emscripte...@googlegroups.com
This is something you would most likely need to do from your own JS/HTML code.   You can hook into the exit of a program using the `postRun` hook on the incoming module object to detect when the first module is done, and you can do whatever you want on your web page, including load new JS code, or navigate somewhere else.

cheers,
sam

--
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 emscripten-disc...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/emscripten-discuss/189c408e-9bc2-4bf4-8714-b0e0a65e9c6an%40googlegroups.com.

Balázs Varga

unread,
Dec 9, 2022, 5:23:43 AM12/9/22
to emscripte...@googlegroups.com
Hi,

Thank you very much for your reply, Sam.

I would also have another question about emscripten_run_script() function. I just tried a very simple call in the main function: 
emscripten_run_script("alert('hi')");
But I got this error in the browser after running the application.
"LinkError: WebAssembly.instantiate(): Import #28 module="env" function="emscripten_run_script" error: function import requires a callable"

Am I missing something?

Thanks in advance for your help,
Balázs

Sam Clegg

unread,
Dec 9, 2022, 1:46:30 PM12/9/22
to emscripte...@googlegroups.com
On Fri, Dec 9, 2022 at 2:23 AM Balázs Varga <balazs....@gmail.com> wrote:
Hi,

Thank you very much for your reply, Sam.

I would also have another question about emscripten_run_script() function. I just tried a very simple call in the main function: 
emscripten_run_script("alert('hi')");
But I got this error in the browser after running the application.
"LinkError: WebAssembly.instantiate(): Import #28 module="env" function="emscripten_run_script" error: function import requires a callable"

Am I missing something?

` emscripten_run_script` is part of emscripten JS library support code.  Are you using the emscripten-generated JS to load your wasm module?  (i.e. are you building with `.js` or `.html` as your output file extension?).





Thanks in advance for your help,
Balázs

'Sam Clegg' via emscripten-discuss <emscripte...@googlegroups.com> ezt írta (időpont: 2022. dec. 6., K, 0:33):
This is something you would most likely need to do from your own JS/HTML code.   You can hook into the exit of a program using the `postRun` hook on the incoming module object to detect when the first module is done, and you can do whatever you want on your web page, including load new JS code, or navigate somewhere else.

cheers,
sam

On Mon, Dec 5, 2022 at 3:30 AM Balázs Varga <balazs....@gmail.com> wrote:
Hi All,

Is it possible somehow to run a wasm app from another wasm app? For example, running the emrun command from a main cpp function, somehow?

int main(int argc, char* argv[])
{
     emrun --serve_after_close foo.html;
}

Thanks for your help, in advance.
Balázs

--
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 emscripten-disc...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/emscripten-discuss/189c408e-9bc2-4bf4-8714-b0e0a65e9c6an%40googlegroups.com.

--
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 emscripten-disc...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/emscripten-discuss/CAL_va28k2vE6v%2Bi2dGiwOmA0SY7ce7%3DZ3cHdbB6UD9838o%2BiaQ%40mail.gmail.com.

--
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 emscripten-disc...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages