
You’d like to be able to call into C++ through functions, not just an executable’s entry point. Often you want fine-grain control and coordination between Node.js and C++. You could certainly develop complex coordination between your C++ and Node applications, but automation works best when you just want to send some input to C++ and wait for the results. One disadvantage though is that there is really only one entry point to your C++ - main. Automation also allows you to integrate with just about every programming language - as long as it can be automated through stdin/stdout or input and output files. When automating a C++ application, you have the advantage of having really clean separation between your JavaScript and C++. For example, if you are looking to compile Rust code into a library that can be integrated with Node.js, check this out! Why use a Shared Library / DLL? This post focuses on C++, but any language that can be compiled into a native shared library can be called from Node.js using these techniques. I’ll also discuss some of the common issues you can run into when converting a legacy C++ application into a callable shared library. This post focuses entirely on compiling your C++ as a shared library or DLL, and calling that code from Node.js using FFI. The second post covered automation in detail, and also introduced the C++ code that I’m focused on calling - a prime number implementation found here.

If you haven’t read the first post, you might want to check that out first, before going forward.


This post is the third in a series of four posts dedicated to showing you how to get your C++ application onto the web by integrating with in Node.js. Calling Native C++ DLLs from a Node.js Web App
