vendredi 3 mars 2017

Force node-gyp to use C++11

So I was messing around with the C/C++ Addons feature with NodeJS, however as I am relatively new to the concept I've run into a large problem. Essentially my C++ program which I have written requires the RegEx library, but when I run node-gyp rebuild I receive the following error.

CXX(target) Release/obj.target/addon/main.o
../main.cpp:15:10: fatal error: 'regex' file not found
#include <regex>
         ^
1 error generated.

When building my project with Xcode (I use a Mac), before I started to turn it into a C/C++ addon, the project built perfectly fine and ran as expected.

I did a bit of digging and I believe that the regex library is only available in C++11, although I am not particularly sure whether node-gyp uses this, so how would I be able to build using this instead of the default, or otherwise include the library manually (if you can do that).

My program looks like so,

#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)

My binding.gyp file looks as follows,

{
  "targets": [
    {
      "target_name": "addon",
      "sources": [ "main.cpp" ]
    }
  ]
}

Thanks

Aucun commentaire:

Enregistrer un commentaire