Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22045

Undefined symbol in native NodeJS module

$
0
0

I'm building a native C++ nodejs module. I have developed it in windows and now I want to run it on linux. The compiler finishes successfully. But when I runrequire('smartparser'), I'm getting the following error:

var a = require('smartparser')Error: .../node_modules/smartparser/build/Release/smartparser.node: undefined symbol: _ZN2v86String9NewSymbolEPKciat Module.load (module.js:356:32)

I'm using Debian (Arch: i386) with GCC-4.7.

Node version: v0.11.3-pre

NPM version: 1.3.10

I'm also getting the following warning:

make: warning:  Clock skew detected.  Your build may be incomplete.

But after little researched, I found out this is caused by wrong local time.

EDIT2: Code

{"author": "deepsy@gmail.com","targets": [    {"target_name": "smartparser","sources": [ "lib/handler.cpp", "lib/analyzer.cpp", "lib/parser.cpp" ],"cflags": ["-std=c++11"          ]    }  ]}

Cpp

Handle<Value> parseHandler(const Arguments& args) {    HandleScope scope;    bool validArguments =         args[0]->IsString() &&        args[1]->IsString() &&         args[2]->IsNumber() &&         args[3]->IsFunction();    if (!validArguments) {        return ThrowException(Exception::TypeError(            String::New("Invalid arguments! Pass the arguments in the following order: {string} text, {string} title, {int} outputlength, {function} callback.")));    }    Local<Array> nodes = Parser(std::string(*String::Utf8Value(args[0]->ToString())),                                std::string(*String::Utf8Value(args[1]->ToString())),                                 int(args[2]->Int32Value()));    const unsigned argc = 2;    Local<Value> argv[argc] = {        Local<Value>::New(Null()),        nodes    };    Local<Function> callback = Local<Function>::Cast(args[3]);    callback->Call(Context::GetCurrent()->Global(), argc, argv);    return Undefined();}Local<Array> Parser(std::string input, std::string title, int sentenceLimit){    Local<Array> nodes = Array::New();    Local<Object> node_obj;    std::size_t pos = 0;    std::size_t closePos = -1;    std::size_t openPos = -1;    int tagID = -1;    int lastTag = -1;    int lastAppended = -1;    // Output array iterator    int id = 0;    while ((pos = input.find('<', pos)) != std::string::npos) {        pos++;        switch (tagID = tagDetect(&input[pos])) {        case Tags::Closing:            // determine what kind of closing tag is            tagID = tagDetect(&input[pos + 1]);            // Is this the closure of the last tag            if (tagID == lastTag && (pos - openPos > MIN_TEXT_LENGTH || lastTag != Tags::Paragraph)) {                // If two tags of same kind are used in sequence skip second                if (lastAppended == lastTag) {                    continue;                }                // Create new object in the array                // Example:                //     { tag: 2, content: "Some content" }                node_obj = Object::New();                node_obj->Set(tag_symbol, Integer::New(lastTag));                node_obj->Set(data_symbol, String::New(                    analyzer.getSummary(title,                                        input.substr(openPos + (lastTag > 1 ? 3 : 2), pos - openPos - (lastTag > 1 ? 3 : 2) - 1),                                        sentenceLimit).c_str()));                nodes->Set(id++, node_obj);                lastAppended = lastTag;                continue;            }            // Clear useless tags            input.erase(pos - 1, input.find('>', pos - 1) - pos + 2);            break;        // Sets a opening tag in the tag detect        case Tags::Paragraph:        case Tags::Heading:            openPos = pos;            lastTag = tagID;            break;        default:            // Clear useless tags            input.erase(pos - 1, input.find('>', pos - 1) - pos + 2);            break;        }    }    // Remove last element from array if its heading elements    if (lastTag == Tags::Heading) {        nodes->Delete(id - 1);    }    return nodes;}

enter image description here


Viewing all articles
Browse latest Browse all 22045

Trending Articles