在本机节点模块中使用PCRE库

时间:2013-10-18 18:27:03

标签: c++ node.js module native pcre

我正在尝试在本机C ++ nodejs模块中使用PCRE库。 我在我的cpp文件中添加了#include "pcre\pcrecpp.h",但我得到了

e:\nativenode\pcre\pcrecpp.h(334): fatal error C1083: Cannot open include file:
 'pcre.h': No such file or directory [E:\nativenode\build\wikiparser.vcxproj]
gyp ERR! build error
gyp ERR! stack Error: `C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe
` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onExit (C:\Program Files\nodejs\node_modules\
npm\node_modules\node-gyp\lib\build.js:267:23)
gyp ERR! stack     at ChildProcess.EventEmitter.emit (events.js:98:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:789:
12)
gyp ERR! System Windows_NT 6.1.7601
gyp ERR! command "node" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modu
les\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd E:\nativenode
gyp ERR! node -v v0.10.12
gyp ERR! node-gyp -v v0.10.0
gyp ERR! not ok
npm ERR! weird error 1
npm ERR! not ok code 0

所以我认为pcre.h文件丢失了,我进入PCRE目录并将pcre.h.generic重命名为pcre.h(所以文件现在存在),但我是得到同样的错误。 我的文件夹看起来像这样

enter image description here

我如何让它运行?我是否需要在某处链接lib或仅包括pcrecpp.h

1 个答案:

答案 0 :(得分:0)

听起来你错过了正确的包含路径。

https://github.com/mscdex/node-pcre似乎将include_dirs字段添加到gyp中,以便构建系统看到包含:

https://github.com/mscdex/node-pcre/blob/master/deps/libpcre/pcre.gyp#L3-L5

'include_dirs': [
  '.',
],