You can take a look at nad (Node Addon 
Development): https://github.com/thlorenz/nad

What it does is take your addon's binding.gyp file and injects it into 
node's node.gyp file.
So, when you compile node.js, your addon will be compiled in as well.
This allows your addon to function just like the built in modules like 
zlib, etc.
nad is somewhat OS X focused because it'll open the project in XCode - but 
you can just as easily produce a Makefile for Linux.

`nad inject` will inject the binding.gyp of the addon into node's node.gyp

Then, you can build node.js as usual, e.g.:
$ ./configure
$ make

Your addon will be compiled into the node binary.

On Monday, August 3, 2015 at 10:30:53 AM UTC-4, Hai Phan wrote:
>
> I'm relatively new to node.js and I have a question about compiling 
> node.js with additional native module. Is there a way to integrate an addon 
> to node.js so that it is ready for use after compile?
>
>
> node.js source code is here <https://github.com/joyent/node>. Some 
> built-in libraries are located in deps/
>
>
> There is a tutorial <https://nodejs.org/api/addons.html> for compiling 
> C++ addon as a module of node.js. After compilation of the module a file 
> "myaddon.node" is generated that can be used with require in node.js 
> application.
>
>
> Is there a way to make the module built-in? I mean I can just compile it 
> together with node.js source code and then deploy to a target machine. So 
> that I can just call
>
>
> var myaddon = require("myaddon");
>
>
> without having to run npm install. There are natives modules such as zlib, 
> http, fs that are integrated into node.js.
>
>
> I found one article 
> <http://joseoncode.com/2012/04/10/writing-your-first-native-module-for-node-dot-js-on-windows/>
>  where 
> a native module is built for node.js on Windows using Visual Studio. Is 
> there a similar way to build node.js with your own module on Linux?
>

-- 
Job board: http://jobs.nodejs.org/
New group rules: 
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nodejs/bdd82d05-8f83-4e32-bf99-002240cae486%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to