使用node.js插件提升库 – segfault

的package.json:

{ "name": "BoostRegexJS", "version": "0.0.1", "description": "Boost::Regex API for node.js", "main": "regex.js", "private": true, "dependencies": { "bindings": "~1.2.1", "nan": "^2.0.0" }, "scripts": { "test": "node regex.js" }, "gypfile": true } 

bindings.gyp

 { "targets": [ { "target_name": "boostregex", "sources": [ "regex.cpp" ], "include_dirs": [ "~/boost/include", "<!(node -e \"require('nan')\")" ], "libraries": [ "~/boost/lib/libboost_regex.so" ], "cflags_cc!": [ "-fno-rtti", "-fno-exceptions" ], "cflags!": [ "-fno-exceptions" ], "conditions": [ ['OS=="mac"', { "xcode_settings": { 'OTHER_CPLUSPLUSFLAGS' : ['-std=c++11','-stdlib=libc++', '-v'], 'OTHER_LDFLAGS': ['-stdlib=libc++'], 'MACOSX_DEPLOYMENT_TARGET': '10.7', 'GCC_ENABLE_CPP_EXCEPTIONS': 'YES' } }], ['OS!="win"', { 'include_dirs': [ 'config/win' ], 'cflags+': [ '-std=c++11' ], 'cflags_c+': [ '-std=c++11' ], 'cflags_cc+': [ '-std=c++11' ], }] ] } ] } 

regex.cpp

 #include <nan.h> #include <string> #include <boost/regex.hpp> void Method(const Nan::FunctionCallbackInfo<v8::Value>& info) { info.GetReturnValue().Set(Nan::New("worldd").ToLocalChecked()); } void Init(v8::Local<v8::Object> exports) { exports->Set(Nan::New("hello").ToLocalChecked(), Nan::New<v8::FunctionTemplate>(Method)->GetFunction()); } NODE_MODULE(boostregex, Init) 

只是因为#include<boost/regex.hpp>我运行这段代码时遇到了段错误:

 var addon = require('bindings')('boostregex'); console.log(addon.hello()); // 'world' 

没有这个包括,插件工作正常..

奇怪,因为它只是头文件..

Boost库编译成功(尝试了clang和gcc,都可以)

FreeBSD,Node.js v4

Anyidea为什么段错误?