Question

I have a large codebase in C that I want to compile into Javascript using emscripten and run in a browser. No problem.

I then want to add a 3rd party javascript library and invoke it from the C code using emscripten's mechanisms.

I've added the calls to the 3rd party js library using the EM_ASM construct. If I compile the C code to html/js files it doesn't see the 3rd party js library.
If I manually edit the html file to add

<script src="3rdPartyLib.js"></script>

it works great.

How do I make enscripten put the <script> tag in there rather than doing it manually?

Was it helpful?

Solution

You can use a shell file with the flag --shell-file <path>. The generated HTML will use that file as a template, so you can include your custom script tag.

From Emscripten's docs

--shell-file <path>
The path name to a skeleton HTML file used when generating HTML output. The shell file used needs to have this token inside it: {{{ SCRIPT }}}.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top