Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7517793
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T01:33:49+00:00 2026-05-30T01:33:49+00:00

I have this simple code of node addon: #include <node.h> #include <v8.h> #include <string>

  • 0

I have this simple code of node addon:

#include <node.h>
#include <v8.h>
#include <string>
#include <vector>

template <class S>
class FooString
{
  protected:
    static std::vector< S > vec_strings;

  public:
    const S &str()  const {  return vec_strings[0]; }
    std::string tostdstring() const;
};

template <>
std::string FooString<std::string>::tostdstring() const {  return str();  }


namespace v8
{
  Handle<Value> Method(const Arguments& args) {
    HandleScope scope;
    return scope.Close(String::New("world"));
  }

  void init(Handle<Object> target) {
    target->Set(String::NewSymbol("hello"),
      FunctionTemplate::New(Method)->GetFunction());
  }
  NODE_MODULE(test, init)
}

it compiles but when I’m runing script which including this addon:

var test = require('./build/Release/test');
console.log(test.hello()); // 'world'

I have got the error message:

node.js:199
        throw e; // process.nextTick error, or 'error' event on first tick
              ^
Error: Unable to load shared library /home/run/git/addontest/build/Release/test.node
    at Object..node (module.js:474:11)
    at Module.load (module.js:350:32)
    at Function._load (module.js:308:12)
    at Module.require (module.js:356:17)
    at require (module.js:372:17)
    at Object.<anonymous> (/home/run/git/addontest/octonode.js:1:74)
    at Module._compile (module.js:443:26)
    at Object..js (module.js:461:10)
    at Module.load (module.js:350:32)
    at Function._load (module.js:308:12)

My g++ version is (Ubuntu/Linaro 4.5.2-8ubuntu4) 4.5.2 and nodejs version is v0.7.5-pre

could you check if you have any problems to compile and run this code?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T01:33:52+00:00Added an answer on May 30, 2026 at 1:33 am

    It looks like it’s not loving the fact that you haven’t allocated space for your static variable anywhere.

    Adding this fixes it for me.

    template <class S>
    std::vector< S > FooString<S>::vec_strings;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code: public void AddNode(string Node) { try { treeView.Nodes.Add(Node); treeView.Refresh(); }
i have a question about this code. class Queue { Node first, last void
I have this simple code that speaks for itself. <script language='javascript"> function check() {}
I am a total beginner in JS/XML. I have this simple code that needs
I've wrote this simple piece of code. And I have a slight problem with
There is probably is simple fix for this but I currently have code similar
I have this sample code for async operations (copied from the interwebs) public class
I have the following object Node : private class Node implements Comparable<Node>(){ private String
So I have made this simple interface: package{ public interface GraphADT{ function addNode(newNode:Node):Boolean; }
Excuse the beginner level of this question. I have the following simple code, but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.