static library

25 views
Skip to first unread message

Alessio Mochi

unread,
Nov 25, 2022, 4:16:09 AM11/25/22
to emscripten-discuss
Hello,
it's possibile create a static library with emscripten to avoid to recompile every time
a common code? If it's possible can explain me how do it on linux?

Sam Clegg

unread,
Nov 27, 2022, 6:33:10 PM11/27/22
to emscripte...@googlegroups.com
With respect to static libraries emscripten works just like your native clang/gcc toolchain.  You can create static libraries using the `emar` tool which is a direct replacement to the normal `ar` tool.   You can then link your static libraries by directly specifying them on the command line, or by using the `-l` + `-L` link flags (just like the native toolchain).

--
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/01e1ccb8-8132-4a89-a555-257184628223n%40googlegroups.com.

Floh

unread,
Dec 2, 2022, 12:27:59 PM12/2/22
to emscripten-discuss
If you are using cmake to setup your build then it works like on any other platform, for instance to declare a static link library:


...and then to link this library to an executable:


...and finally to configure and build, you can use the emcmake wrapper script that's included in the Emscripten SDK, this invokes cmake with the right cross-compiling toolchain file, e.g. see:


Cheers!
Reply all
Reply to author
Forward
0 new messages