This repository was archived by the owner on Apr 22, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 7.3k
statically linked executable
rofl0r edited this page Sep 9, 2014
·
4 revisions
Node.js has support to be compiled as a fully statically linked executable just by using the --fully-static
configure flag. That way it doesn't require external dynamic libraries (.so, .dll, .dylib...) and it's main purpose is for embedded platforms. Though, it's somewhat experimental and has some issues you need to know before using it:
- it's dependent of the C lib used: the standard glibc (found on Ubuntu, for example) cannot be used to build fully statically linked executables, as some components are designed such that they require loading dynamic libs for some functionality. This doesn't happen with other alternative C libs like musl, uclib or DietLib, for example.
-
doesn't work with MacOS X developer tools: vanilla gcc compiler on MacOS X don't recognize the
-static
flag since it's intended to use only dynamic linking. It could work with other compilers (installed with homebrew or macports, for example), but this has not been tested. -
there can be compilation issues: not directly related with static compilation, but for example OpenSSL doesn't compile correctly using the musl C lib. Solutions are to use the
--no-ssl
configure flag to disable it, or patch OpenSSL. If you find any of this, please open an issue. -
it could not load compiled modules: some C libs like musl (and seems glibc too) use a stripped-down version of the
dlopen()
function when included in statically linked executables, so loading of some Node.js compiled modules could fail. Requiring pure Javascript modules will work as expected, though.