Skip to content

Include C++ static library from rust library for C++ node extension

Notifications You must be signed in to change notification settings

andruhon/rust-in-node-cpp-back-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rust in node examples

Work still in progress

Experimenting with adding C++ lib back to Rust extension for NodeJS addon.

What's inside:

  • C++ static library ./lib/mylib.cc
  • Rust dynamic library in ./src/embed.rs (linked with mylib.cc)
  • Native NodeJS C++ addon ./src/addon.cc using ./src/embed.rs library

See more general Rust in node examples here: https://github.com/andruhon/rust-in-node-examples

Installation

> npm install > npm run build

Running

> node index.js

Why

On windows it is not really possible to embed node extensions compiled with GCC back into NodeJS, because NodeJS for Windows is compiled with MSVC and addons should be compiled and linked with MSVC as well. So it is not possible to use custom build script which uses gcc crate for ths purpose.

TODO

  • Tests
  • More docs

Links

About

Include C++ static library from rust library for C++ node extension

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published