Thursday, 8 August 2013

Building NodeJs module with boost (or any other library for that matter)

Building NodeJs module with boost (or any other library for that matter)

I'm trying to build a nodejs module with C++ and Ubuntu 13.04 using some
boost headers as shown below:
#include <iostream>
#include <string>
#include <node/node.h>
#include <v8.h>
#include <boost/lexical_cast.hpp>
using namespace std;
using namespace v8;
Handle<Value> Method(const Arguments& args) {
HandleScope scope;
std::string foobar = "8";
return scope.Close(String::New("world"));
}
void init(Handle<Object> exports){
exports->Set(String::NewSymbol("Hello"),
FunctionTemplate::New(Method)->GetFunction());
}
NODE_MODULE(hello, init)
However, when compiling with node-gyp, I get the following errors:
sam@ubuntu:~/workspace_cpp/NodeTest/src$ node-gyp build gyp info it worked
if it ends with ok gyp info using node-gyp@0.10.9 gyp info using
node@0.10.15 | linux | x64 gyp info spawn make gyp info spawn args [
'BUILDTYPE=Release', '-C', 'build' ] make: Entering directory
/home/sam/workspace_cpp/NodeTest/src/build' CXX(target)
Release/obj.target/hello/NodeTest.o In file included from
/usr/include/boost/numeric/conversion/converter.hpp:14:0, from
/usr/include/boost/numeric/conversion/cast.hpp:33, from
/usr/include/boost/lexical_cast.hpp:66, from ../NodeTest.cpp:13:
/usr/include/boost/numeric/conversion/converter_policies.hpp: In member
function 'void
boost::numeric::def_overflow_handler::operator()(boost::numeric::range_check_result)':
/usr/include/boost/numeric/conversion/converter_policies.hpp:162:31:
error: exception handling disabled, use -fexceptions to enable make: ***
[Release/obj.target/hello/NodeTest.o] Error 1 make: Leaving
directory/home/sam/workspace_cpp/NodeTest/src/build' gyp ERR! build error
gyp ERR! stack Error: make failed with exit code: 2 gyp ERR! stack at
ChildProcess.onExit
(/usr/local/lib/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 Linux 3.8.0-19-generic gyp ERR! command "node"
"/usr/local/bin/node-gyp" "build" gyp ERR! cwd
/home/sam/workspace_cpp/NodeTest/src gyp ERR! node -v v0.10.15 gyp ERR!
node-gyp -v v0.10.9 gyp ERR! not ok
I cannot find anything on the web for how to get node-gyp to build with
other libraries such as boost. Does anybody have any insight or experience
with this? My ultimate goal is to make a SOAP module using gsoap.
EDIT I'm assuming that I have to edit my binding.gyp file in some way to
allow for boost to be compiled. As it sits, this file currently looks like
this:
{ "targets": [ { "target_name": "hello", "sources": [ "NodeTest.cpp" ] } ] }

No comments:

Post a Comment