Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Linking with libnode.so When Building for NodeJS-mobile on Android #1661

Open
vincent-herlemont opened this issue Jul 19, 2023 · 2 comments

Comments

@vincent-herlemont
Copy link

vincent-herlemont commented Jul 19, 2023

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.

Related to JaneaSystems/nodejs-mobile-gyp#4 (comment)

# 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?

@yorkie
Copy link

yorkie commented Dec 27, 2023

Node.js provides linked binding for this usecase, this could be possible to work with napi-rs IMO.

@Kreijstal
Copy link

you might get away which just looking for the path in napi build.rs and linking statically

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants