4

I'm working on a Node.js wrapper module for a colleagues C library. The library is created in Shared Object (.so) form for dynamic linking.

My CPP module file begins with

#include "path/to/lib/source/lib.h"

and is built with the following wscript

def set_options(ctx):
    ctx.tool_options('compiler_cxx')

def configure(ctx):
    ctx.check_tool('compiler_cxx')
    ctx.check_tool('node_addon')
    ctx.env.append_value('LINKFLAGS', ['-l:lib.so', '-L/path/to/lib.so/'])

def build(ctx):
    t = ctx.new_task_gen('cxx', 'shlib', 'node_addon')
    t.source = ['module.cpp']
    t.target = 'module'

When I then proceed to call into my module, which in turns call the library, i get the following error:

node: symbol lookup error: <path/to/module.node>:
undefined symbol: <name of library call>

I tried dumping the dependencies of the module with 'ldd module.node' and I got a little suspicious as it doesn't mention my .so file.

Any help is much appreciated!

justkris
  • 800
  • 4
  • 15

1 Answers1

1

Do you know if the dynamic linker can find your library? Try adding the library path to your LD_LIBRARY_PATH. You can run this in the shell before you invoke Node with your test script:

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/path/to/lib.so/
node test-script.js

(On a Mac, that would be DYLD_LIBRARY_PATH.)

Guan Yang
  • 1,202
  • 8
  • 6