Replies: 1 comment 2 replies
-
Hey, I totally get the struggle Building a statically linkable libnode isn’t officially supported by Node.js, and it’s notoriously tricky. The build system is really set up for producing the CLI (the node binary) rather than a reusable static library. Most folks who have managed something similar usually end up maintaining their own fork or heavy patch set, and even then, keeping up with Node releases can be a pain. That is why tools like metacall/libnode exist. They do a ton of patching/automation behind the scenes. If you absolutely need static linking, you might have to go down the rabbit hole of forking and customizing the build (as you started). Otherwise, using dynamic linking with the shared library is much more straightforward and supported. Sorry there isn't a smoother answer. It’s a bit of a rabbit hole! If you are okay with dynamic linking for your use case, I would recommend going that route for your sanity. Good luck. This is not an easy one! If you make any progress, I’d love to hear about it. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi all, I am trying to build libnode such that it produces a statically linkable library I can embed within my application.
It's okay for system dependencies that the Nodejs CLI links dynamically to remain dynamic (like openssl) - I don't need them to be statically included because I am essentially recreating the Nodejs CLI.
I want to produce libraries for
macos-x64
macos-arm64
linux-x64
linux-arm64
andwindows-x64
.I have tried several approaches without success, namely:
And combinations of the flags/patches
I have tried this on Fedora 41 without success so I also tried running these commands within docker containers:
Once I figure it out I will repeat these steps on MacOS and Windows.
References
Beta Was this translation helpful? Give feedback.
All reactions