2.cmd 进入dos界面,切换到源码所在目录,执行vcbuild.bat release
3.制作开发需要的头文件和库等等,此处命名为node.bat,将它保存在代码文件中编译
点击(此处)折叠或打开
-
@echo off
-
if "%1"=="" goto help
-
mkdir "%1"
-
mkdir "%1"\include
-
-
-
copy /y src\node.h "%1"\include
-
copy /y src\node_object_wrap.h "%1"\include
-
copy /y src\node_buffer.h "%1"\include
-
copy /y src\node_version.h "%1"\include
-
-
-
copy /y deps\v8\include\*.h "%1"\include\
-
-
-
copy /y deps\uv\include\*.h "%1"\include\
-
-
-
mkdir "%1"\include\uv-private
-
copy /y deps\uv\include\uv-private\*.h "%1"\include\uv-private
-
-
-
mkdir "%1"\include\ev
-
copy /y deps\uv\src\ev\*.h "%1"\include\ev
-
-
-
mkdir "%1"\include\c-ares
-
copy /y deps\uv\include\ares.h "%1"\include\c-ares
-
copy /y deps\uv\include\ares_version.h "%1"\include\c-ares
-
-
-
mkdir "%1"\lib
-
copy /y Release\node.lib "%1"\lib
-
-
-
copy /y Release\node.exe "%1"
-
-
-
echo =================================
-
echo Install
-
goto exit
-
-
-
if not errorlevel 0 echo Error "install-path" & goto exit
-
-
-
:help
-
echo nodins.bat install-path
-
-
- :exit
4.用Visual Studio 2010或Visual Studio 2012创建一个DLL工程空白工程
配置工程:
在工程属性的配置属性-常规中将目标文件扩展名改为.node;
在工程属性的配置属性-C/C++-常规-附加包含目录添加头文件目录为:D:\nodejs\include
在工程属性的配置属性-链接器-常规-附加库目录添加目录:D:\nodejs\lib
在工程属性的配置属性-链接器-输入-附加依赖项添加lib库:node.lib
注:win7 64位平台下使用在win764位平台下编译,工程编译也设置位x64
如果还存在问题,在网上下载64位的node.lib,将lib文件中的node.lib替换
编译生成后在D:\hellonode\hellonode中生成一个文件xxx.node;
5..node文件将作为node.js的模块加载使用