Node.js module - add link dependency

I am working on a Node.js module for a C colleagues library. The library is created in the form of a shared object (.so) for dynamic linking.

My CPP module file starts with

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

and 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 the call to my module, which in turn calls the library, I get the following error:

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

I tried to reset module dependencies using 'ldd module.node' and I am a bit suspicious since it does not mention my .so file.

Any help is much appreciated!

+4
source share
1 answer

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

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

(On a Mac, this will be DYLD_LIBRARY_PATH .)

+1
source

Source: https://habr.com/ru/post/1395920/


All Articles