简体   繁体   中英

dyld: Symbol not found: _JNI_CreateJavaVM

What does this error mean?

What do I need to do to resolve it?

I'm trying to run a java based module for node.js (specifically, xslt4node ) on Mac OS El Captain but every time I get this error. Everything seems to work OK for windows users. The full error is below:

dyld: lazy symbol binding failed: Symbol not found: _JNI_CreateJavaVM Referenced from: /projects/main-project/node_modules/java/build/Release/nodejavabridge_bindings.node Expected in: flat namespace

dyld: Symbol not found: _JNI_CreateJavaVM Referenced from: /projects/main-project/node_modules/java/build/Release/nodejavabridge_bindings.node Expected in: flat namespace

I found Undefined symbols for architecture x86_64: JNI_CreateJavaVM OS-X Xcode which is the closest I could find that explains my exact problem, but I'm not using xcode for development, I'm on a node.js platform.

Has anyone else seen this before? What does it mean?

So far I have tried:

  1. Changing Java versions
  2. Deleting and rebuilding node_moudles
  3. Adding JVM capabilities <string>JNI</string>
  4. Uninstalling Java, per documentation here: https://www.java.com/en/download/help/mac_uninstall_java.xml running those commands does nothing:

user:~ kawnah$ sudo rm -fr /Library/PreferencePanes/JavaControlPanel.prefPane user:~ kawnah$ sudo rm -fr ~/Library/Application\\ Support/Java user:~ kawnah$ java -version java version "9.0.1" Java(TM) SE Runtime Environment (build 9.0.1+11) Java HotSpot(TM) 64-Bit Server VM (build 9.0.1+11, mixed mode)

  1. Trying different version of node (7.10.0)
  2. Completely uninstalling node/npm, and reinstalling

Basically, what this error is telling you is that there's an issue with a symbolic link to a file in this module you're trying to use.

Mac OS X's DYLD is the OS's dynamic linker . Its job is, more or less, to load shared libraries for the OS when resources are requested.

There are a number of reasons this could happen, from a failed update process on the module itself to drive corruption, etc.

The most common fix (1) to this specific issue is to delete your node_modules folder and run a fresh NPM install in both the local and global directories:

rm -rf node_modules/
npm install

You could alternatively attempt a npm rebuild, but a clean install is generally the best route to go.


  1. from the accepted answer here

Try to manually enable JNI by editing /Library/Java/JavaVirtualMachines/<version>.jdk/Contents/Info.plist and adding JNI as an option in JVMCapabilities:

<key>JVMCapabilities</key>
<array>
    ...
    <string>JNI</string>
</array>

As found in https://github.com/joeferner/node-java/issues/223#issuecomment-110408072

Try an xcode-select --install and then npm rebuild Check this thread, problem seems to be apple's xcode (in your case it could be the c++ compiler),discussion is for ruby vm but might be similar for jvm.

Generally check/update your c++/c compiler and then try anything else ,like choosing another java version and adding JNI to capabilities. Last thing to mention node-gyp needs python version 2.x as mentioned in the README of node-java.

I FINALLY figured it out!

I needed this npm package for node-java to work properly on my machine https://www.npmjs.com/package/winreg

npm install winreg resolved all issues

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM