I'm trying to use napi-rs to create a native Node.js module for use with NodeJS-mobile on Android. In order to get native modules to work correctly with NodeJS-mobile on Android, they need to be linked with NodeJS-mobile's libnode.so at build time. This is because Android requires an entry for libnode.so in the ELF header of the module, or it will not look for the linked functions at runtime.
# While loading a native node module, Android needs to have a
# (NEEDED) entry for libnode.so, or it won't be able to locate
# referenced symbols.
# We link to the binary libraries that are distributed with the
# nodejs-mobile headers so the (NEEDED) entry is created
[ 'target_arch=="arm"', {
'libraries': ['>(node_root_dir)/bin/armeabi-v7a/libnode.so'],
}],
[ 'target_arch=="arm64"', {
'libraries': ['>(node_root_dir)/bin/arm64-v8a/libnode.so'],
}],
[ 'target_arch=="x86"', {
'libraries': ['>(node_root_dir)/bin/x86/libnode.so'],
}],
[ 'target_arch=="x86_64"', {
'libraries': ['>(node_root_dir)/bin/x86_64/libnode.so'],
}],
Would it be possible to deal with that with napi-rs?
I'm trying to use
napi-rs
to create a native Node.js module for use with NodeJS-mobile on Android. In order to get native modules to work correctly with NodeJS-mobile on Android, they need to be linked with NodeJS-mobile'slibnode.so
at build time. This is because Android requires an entry forlibnode.so
in the ELF header of the module, or it will not look for the linked functions at runtime.Related to https://github.com/JaneaSystems/nodejs-mobile-gyp/issues/4#issuecomment-459449632
Would it be possible to deal with that with
napi-rs
?