Closed gonzus closed 4 years ago
Have a look at sodium-native
, does something similar.
You might also like the --artifacts
option to copy additional files to prebuilds/
.
Thanks @vweevers -- good info. I see sodium-native
ends up building these prebuilt objects:
$ tree prebuilds/
prebuilds/
└── linux-x64
├── libsodium.so.23
└── node.napi.node
I guess, then, that when you install this module and load node.napi.node
via a require
, the dynamic linker finds and loads the libsodium.so.23
file?
Hum... I guess this is the glue to it all:
binding.gyp: 'libraries': [ "-Wl,-rpath=\\$$ORIGIN"]
Just for my education, do you happen to know what that ORIGIN
variable means, and where that definition comes from?
Anyway, this makes sense:
$ ldd prebuilds/linux-x64/node.napi.node
linux-vdso.so.1
libsodium.so.23 => .../sodium-native/prebuilds/linux-x64/libsodium.so.23
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0
/lib64/ld-linux-x86-64.so.2
ORIGIN is a Linux feature where you make the link relative to where your binary is.
Thanks for all the hints and pointers, it is working fine for me.
More than an issue, this is a question.
I have a C library
libfoo
(that I wrote) that I am wrapping in a NodeJS wrapperFooNAPI
. The C library is built and installed outside the NodeJS wrapper, via aMakefile
. As part of the installation for the library, theMakefile
puts header files in.../include/foo/
, a shared object in.../lib/libfoo.so
and some data files in.../share/foo/
.I can build
FooNAPI
by putting all the correct directories and flags inbinding.gyp
. Now, I would like to includelibfoo.so
and the files in.../share/foo/
in theFooNAPI
prebuilt objects. Is there a way to do this with prebuildify? Or is this something I need to configure inbinding.gyp
?If I later install the
FooNAPI
wrapper on another machine, and it brings in with it the shared object and the data files as part of the prebuilds, how do I get the dynamic linker on that machine to load the shared object from thenode_modules/prebuilds
directory?Thanks for any hints!