On Tue, Oct 14, 2014 at 1:15 PM, Michael Pyne <[email protected]> wrote: > I'm looking for help with building an addon for Node.js on AIX. > > I'm working on an AIX 7.1 powerpc box, with Node.js 0.11.13 for powerpc from > andrewlow/node on GitHub. > Make is GNU Make v 3.81; gcc is v4.8.2. > > I don't have root access on the system, so I have installed Node to a folder > in my homespace. > > At the moment, I have a very simple "Hello, World" addon that I'm trying to > use on AIX. The same cpp file has been added to a Visual Studio (2010) > project on Windows 7, which has built successfully and can be required in > Node. > > I am able to build the addon using node-gyp on AIX; I copy the resulting > .node file to the same folder as my node executable; when I try to require > the add on, it fails with: > > "Error: Module did not self-register. > at Error (native) > at Module.load (module.js:349:32) > at Function.Module._load (module.js:305:12) > at Module.require (module.js:357:17) > at require (module.js:373:17) > at repl:1:9 > at REPLServer.defaultEval (repl.js:130:27) > at bound (domain.js:257:14) > at REPLServer.runBound [as eval] (domain.js:270:12) > at REPLServer.<anonymous> (repl.js:277:12)" > > The addon is defined in a single file: > > #include <v8.h> > #include <node.h> > #include <node_object_wrap.h> > #include <string.h> > > using namespace node; > using namespace v8; > > class HelloWorld : public ObjectWrap > { > public: > static Persistent<Function> constructor; > > static void init(Handle<Object> exports) > { > Isolate* isolate = Isolate::GetCurrent(); > Local<FunctionTemplate> tpl = FunctionTemplate::New(isolate, New); > tpl->SetClassName(String::NewFromUtf8(isolate, "HelloWorld")); > tpl->InstanceTemplate()->SetInternalFieldCount(1); > > NODE_SET_PROTOTYPE_METHOD(tpl, "hello", Method); > > constructor.Reset(isolate, tpl->GetFunction()); > exports->Set(String::NewFromUtf8(isolate, "HelloWorld"), > tpl->GetFunction()); > } > > static void Method(const FunctionCallbackInfo<Value>& args) > { > Isolate* isolate = Isolate::GetCurrent(); > HandleScope scope(isolate); > args.GetReturnValue().Set(String::NewFromUtf8(isolate, "world")); > } > > static void New(const FunctionCallbackInfo<Value>& args) > { > Isolate* isolate = Isolate::GetCurrent(); > HandleScope scope(isolate); > HelloWorld* hw = new HelloWorld(); > hw->Wrap(args.This()); > args.GetReturnValue().Set(args.This()); > } > }; > > Persistent<Function> HelloWorld::constructor; > > extern "C" { > static void init(Handle<Object> target) > { > HelloWorld::init(target); > } > > NODE_MODULE(hello, init); > } > > I would be very grateful for any guidance on this.
Starting with v0.11.11, add-ons are supposed to self-register using a constructor function. That's what the NODE_MODULE() macro does, it generates a function with __attribute__((constructor)), and I believe those are notoriously unreliable on AIX, see e.g. [0]. I don't have a solution for you but at least now you know where to start digging. [0] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54791 -- Job board: http://jobs.nodejs.org/ New group rules: https://gist.github.com/othiym23/9886289#file-moderation-policy-md Old group rules: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines --- You received this message because you are subscribed to the Google Groups "nodejs" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/nodejs/CAHQurc8WE-WP0bmEGRqLUDocqLZ-u-kt5DuM4Nt7VfQZzpmD-A%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
