|
| 1 | +# Creating a nodejs native .Net extension |
| 2 | +This short writeup will guide you through creating a simple node.js addon |
| 3 | + |
| 4 | +## Before we begin |
| 5 | +1. Read [this](http://coderesearchlabs.com/articles/BNWCA.pdf) short description on how to build a simple nodejs addon on windows. |
| 6 | +2. Download node.js [sources](http://nodejs.org/#download). |
| 7 | +3. Make sure you have [Python 2.x](http://www.python.org/download/) installed (not 3.x). |
| 8 | +4. Build node sources by running `vcbuild.bat'. |
| 9 | +5. Verify that node.lib is located under the Debug/ directory. |
| 10 | + |
| 11 | +## Creating a .Net node addon |
| 12 | +1. Fire up VS2010 and create a new C++ Empty CLR project. |
| 13 | + |
| 14 | +2. Open the project properties (Click Alt+Enter while the project file is selected) |
| 15 | +3. Set the project type and extension project type should be *dll* and the extension should be *.node* |
| 16 | + |
| 17 | +4. Set the include directories as follows (replace paths with the local nodejs source path). |
| 18 | + |
| 19 | +5. Set the libraries directories as follows (replace paths with the local nodejs source path). |
| 20 | + |
| 21 | +6. Add a new CPP file and call it SOME_PREFIX_Addon.cpp. |
| 22 | +This file will hold the actual addon definitions and dll entry point. |
| 23 | +7. Open the property pages of the **new CPP file** you created. |
| 24 | +8. Change the "Common Language Runtime Support" option to **No Common Language RunTime Support** |
| 25 | + |
| 26 | + |
| 27 | +## What's next? |
| 28 | +* use the project provided here as an initial implementation. |
| 29 | +* take a look at the following [html presentation](http://kkaefer.github.com/node-cpp-modules/#api-how-hard-to-misuse). |
| 30 | +the ppt explains the different steps necessary to register a class with V8. |
| 31 | +* start rocking! |
0 commit comments