我最近在尝试使用NodeJS的C/C++插件功能,但由于我对这个概念相对较新,遇到了一个大问题。我编写的C++程序需要RegEx库,但当我运行node-gyp rebuild
时,会收到以下错误信息。
CXX(target) Release/obj.target/addon/main.o
../main.cpp:15:10: fatal error: 'regex' file not found
#include <regex>
^
1 error generated.
当我使用Xcode(我使用Mac)构建我的项目时,在将其转换为C/C++插件之前,该项目构建得非常完美,并按预期运行。
我进行了一些调查,我认为正则表达式库仅在C++11中可用,尽管我不确定node-gyp是否使用此库,那么我该如何使用它来替代默认值进行构建,或者手动包含库(如果可以的话)。
我的程序看起来像这样,
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <regex> <-- Throws Error Here
#include <node.h>
using namespace v8;
// Rest of the code (compiler doesn't reach past this point)
我的binding.gyp文件如下所示,
{
"targets": [
{
"target_name": "addon",
"sources": [ "main.cpp" ]
}
]
}
谢谢