# Call C++ from Node-Red (Node.js)

**URL:** <https://discourse.nodered.org/t/call-c-from-node-red-node-js/90217>\
**Category:** Developing Nodes\
**Tags:** native, cpp, binary, interface, node-api\
**Created:** [16 August 2024 12:12 UTC](https://discourse.nodered.org/t/call-c-from-node-red-node-js/90217 "2024-08-16T12:12:07Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![iiot2k](https://avatars.discourse-cdn.com/v4/letter/i/8baadc/32.png) [@iiot2k](https://discourse.nodered.org/u/iiot2k)\
**Post date:** [16 August 2024 12:12 UTC](https://discourse.nodered.org/t/call-c-from-node-red-node-js/90217/1 "2024-08-16T12:12:07Z")

</div>

Hello,  
Node-Red and Node.js are essentially written in C++.  
Therefore, there is a C++ interface to Node.js.  
Most of my nodes are written with it.  
I wanted to share a document with you on how it works.  
Have fun.

[call\_cpp\_from\_nodejs.pdf](https://discourse.nodered.org/uploads/short-url/8O84DLhTsbyCqTSw6Vu857fSph9.pdf) (272.5 KB)

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [16 August 2024 13:04 UTC](https://discourse.nodered.org/t/call-c-from-node-red-node-js/90217/2 "2024-08-16T13:04:30Z")

</div>

Love it. thanks for sharing.

Do you happen to have similar articles for `go`, `zig` and `rust` 🤞

---

<div class="post-metadata">

**Author:** ![iiot2k](https://avatars.discourse-cdn.com/v4/letter/i/8baadc/32.png) [@iiot2k](https://discourse.nodered.org/u/iiot2k)\
**Post date:** [16 August 2024 13:10 UTC](https://discourse.nodered.org/t/call-c-from-node-red-node-js/90217/3 "2024-08-16T13:10:26Z")

</div>

No, but for rust look here:

> **[Home – NAPI-RS](https://napi.rs/)**
>
> NAPI-RS is a framework for building Node.js addons in Rust.

---

<div class="post-metadata">

**Author:** ![marcus-j-davies](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marcus-j-davies/32/103435_2.png) [@marcus-j-davies](https://discourse.nodered.org/u/marcus-j-davies)\
**Post date:** [16 August 2024 16:10 UTC](https://discourse.nodered.org/t/call-c-from-node-red-node-js/90217/4 "2024-08-16T16:10:15Z")

</div>

Que: Node Red Nodes that use licensing and IP protection 🕶

Very cool writeup @iiot2k 🙏

(I have tagged this post with a few things for the crawlers)

---

<div class="post-metadata">

**Author:** ![marcus-j-davies](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marcus-j-davies/32/103435_2.png) [@marcus-j-davies](https://discourse.nodered.org/u/marcus-j-davies)\
**Post date:** [16 August 2024 16:24 UTC](https://discourse.nodered.org/t/call-c-from-node-red-node-js/90217/5 "2024-08-16T16:24:03Z")

</div>

I'm not a C++ guy (.NET Fra.... cough, cough)

Could you use this as a carrier/proxy? to utilise other libs not natively compiled for Node?

Example: We use Barracuda Firewall appliances, and their comms are IP'd to Shizzle!  
and we must use their provided Dll to communicate with the hardware, will be great to import that lib into a Node RED Node - using your guide, as the basis for a carrier to dip into their lib

---

<div class="post-metadata">

**Author:** ![iiot2k](https://avatars.discourse-cdn.com/v4/letter/i/8baadc/32.png) [@iiot2k](https://discourse.nodered.org/u/iiot2k)\
**Post date:** [16 August 2024 17:12 UTC](https://discourse.nodered.org/t/call-c-from-node-red-node-js/90217/6 "2024-08-16T17:12:28Z")

</div>

Hi Marcus,  
Hope I understood your question correctly.  
You can use any C++ library (dll or .so).  
In the end, the extension .node is a dll or .so  
For example, I included the SQLite library and all SQL calls were encapsulated in the .node.  
Of course, you have to be careful with multi-threads.  
Node.js is single-threaded by nature.  
This can cause problems.  
But this problem can be solved if you are familiar with the thread mechanism in Linux or Windows.

Derya

---

<div class="post-metadata">

**Author:** ![marcus-j-davies](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marcus-j-davies/32/103435_2.png) [@marcus-j-davies](https://discourse.nodered.org/u/marcus-j-davies)\
**Post date:** [16 August 2024 17:14 UTC](https://discourse.nodered.org/t/call-c-from-node-red-node-js/90217/7 "2024-08-16T17:14:51Z")

</div>

> [@iiot2k](#):
>
> For example, I included the SQLite library and all SQL calls were encapsulated in the .node.

☝ that.... answered my question - cool!

Thanks

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [15 October 2024 17:15 UTC](https://discourse.nodered.org/t/call-c-from-node-red-node-js/90217/8 "2024-10-15T17:15:35Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
