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

cannot load native addon on android due to failed to locate symbol #70

Open
marsbible opened this issue May 16, 2018 · 2 comments
Open

Comments

@marsbible
Copy link

  • Version: 0.1.4
  • Platform: Android
  • Subsystem: Native Addon

Hi all,
I just built a native C++ addon by NDK r16b, target arch is arm64,it seems that nodejs-mobile
doesn't exports symbols to the C++ module, dlopen() failed due to the symbol miss.
Any solution or workaround ?
Thanks.

buffertools.tar.gz

05-16 11:27:02.812 28954-28984/com.yourorg.sample E/NODEJS-MOBILE: /data/data/com.yourorg.sample/files/nodejs-project/node_modules/buffertools/buffertools.js:26
if (e.code !== 'MODULE_NOT_FOUND') throw e;
^

Error: dlopen failed: cannot locate symbol "_ZNK2v85Value10Int32ValueEv" referenced by "/data/data/com.yourorg.sample/files/nodejs-project/node_modules/buffertools/build/Release/buffertools.node"...
    at Object.Module._extensions..node (module.js:653:18)
    at Module.load (module.js:545:32)
    at tryModuleLoad (module.js:508:12)
    at Function.Module._load (module.js:500:3)
    at Module.require (module.js:568:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/data/data/com.yourorg.sample/files/nodejs-project/node_modules/buffertools/buffertools.js:24:20)
    at Module._compile (module.js:624:30)
    at Object.Module._extensions..js (module.js:635:10)
    at Module.load (module.js:545:32)
@jaimecbernardo
Copy link
Member

Hi, @marsbible ,

Did you use the nodejs-mobile released headers, too?

Regarding dlopen, there are some differences between Android and Linux, described in this issue: android/ndk#201 (comment)
Basically, the android shared library has to be linked to libnode for the symbols to be found at runtime. In the experimental native module support feature for the plugins we add this to the nodejs-mobile headers' common.gypi so gyp does the linking: https://github.com/janeasystems/nodejs-mobile-react-native/blob/05e1748831bca8b8f053dcf80a348f3dc782596c/android/libnode/include/node/common.gypi#L412-L433

In the plugins, we use environment variables while running the build to make sure the nodejs-mobile headers from the plugin are used: https://github.com/janeasystems/nodejs-mobile-react-native/blob/05e1748831bca8b8f053dcf80a348f3dc782596c/android/build.gradle#L294

I hope this is helpful in helping you solve your problem.

@marsbible
Copy link
Author

@jaimecbernardo Thank you very much, your info is very helpful, i'll have a try.

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

No branches or pull requests

2 participants