0
所以我用NodeJS搞亂了C/C++的Addons特性,但是因爲我對於遇到大問題的概念比較陌生。本質上,我寫的C++程序需要RegEx庫,但是當我運行node-gyp rebuild
時,出現以下錯誤。強制node-gyp使用C++ 11
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" ]
}
]
}
感謝