On Fri, Feb 3, 2012 at 01:40, Zenna Tavares <[email protected]> wrote: > I am trying to compile a node module. I had two methods in mind, both of > which have failed and I would appreciate some help. > > First, I tried to compile the module without using node-waf. > I attempted this according to the instructions found in the second question > here http://stackoverflow.com/questions/6662251/build-node-js-addon-without-node-waf > . > The test example compiles into a node module at least but does not load in > node. The error is simply cannot load shared module. > > I switched to using node-waf with the build script below. In this case I > compile my external code into a static library and try to link within > node-waf. I admit I have a poor understanding of node-waf, but want things > to just work. > I tried using uselib='MOVE_HEAD' and also I tried using > bld.env.append_value('LINKFLAGS', '-lmove_head') as suggested in a similar > topic in this group , but both of these result in the same problem: > The module, compiles and loads, but when I attempt to call a function which > should be statically linked, I get the following fatal error. > > dyld: lazy symbol binding failed: Symbol not found: > __ZN4yarp2os7Network4initEv > Referenced from: > /Users/zennatavares/repos/robocop/cxx/build/Release/hello.node > Expected in: flat namespace > > dyld: Symbol not found: __ZN4yarp2os7Network4initEv > Referenced from: > /Users/zennatavares/repos/robocop/cxx/build/Release/hello.node > Expected in: flat namespace > > Thank you, code snippets below: > > My wscript: > > srcdir = '.' > blddir = 'build' > VERSION = '0.0.1' > > def set_options(opt): > opt.tool_options('compiler_cxx') > > def configure(conf): > conf.check_tool('compiler_cxx') > conf.check_tool('node_addon') > libpath = ['/Users/zennatavares/repos/robocop/build/cxx'] > includes = ['/Users/zennatavares/repos/robocop/cxx'] > libmove_head = conf.check(lib="move_head", > libpath=libpath, > uselib_store='MOVE_HEAD', > mandatory=True) > > def build(bld): > obj = bld.new_task_gen('cxx', 'shlib', 'node_addon', uselib='MOVE_HEAD') > bld.env.append_value('LINKFLAGS', '-lmove_head') > obj.target = 'hello' > obj.source = 'hello.cc' > > And for good measure my simple module: > > #include <node.h> > #include <v8.h> > #include "move_head.h" > > using namespace v8; > > Handle<Value> Method(const Arguments& args) { > HandleScope scope; > move_head(0,69); > return scope.Close(String::New("world")); > } > > void init(Handle<Object> target) { > target->Set(String::NewSymbol("hello"), > FunctionTemplate::New(Method)->GetFunction()); > } > NODE_MODULE(hello, init)
Have a look here: http://groups.google.com/group/nodejs/browse_thread/thread/d0720af27dc072f9 -- Job Board: http://jobs.nodejs.org/ Posting guidelines: 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 post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
