Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Using PCRE library in native node modules

Using PCRE library in native node modules

Problem

I'm trying to use the PCRE library in native C++ nodejs modules. I added #include "pcre\pcrecpp.h" in my cpp file, but I'm getting

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

so I thought the pcre.h file is just missing, I went in the PCRE dir and renamed pcre.h.generic to pcre.h ( so the file now exists ), but I'm getting the same error. My folder looks like this

How I can get it running? Do I need to link the lib somewhere or just including pcrecpp.h is enought?

Problem courtesy of: Deepsy

Solution

It sounds like you are missing the proper include path.

https://github.com/mscdex/node-pcre appears to add the include_dirs field to gyp so that the build system sees the include:

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

'include_dirs': [
  '.',
],
Solution courtesy of: SheetJS

Discussion

View additional discussion.



This post first appeared on Node.js Recipes, please read the originial post: here

Share the post

Using PCRE library in native node modules

×

Subscribe to Node.js Recipes

Get updates delivered right to your inbox!

Thank you for your subscription

×