未定义的符号:.JNI_GetDefaultJavaVMInitArgs和.JNI_CreateJavaVM for npm install java

时间:2015-08-25 14:36:18

标签: java node.js npm aix node-java

我在IBM AIX 7.1上,在/ usr / ibm-java-ppc64-71上安装了ibm jdk

我必须运行命令npm install java --javahome = $ JAVA_HOME否则它会说有未定义的变量'javahome'。

以下是我的Env Vars:

export LD_LIBRARY_PATH=/usr/lib:/opt/freeware/lib64
export PATH=/usr/bin:/etc:/usr/sbin:/usr/ucb:/usr/bin/X11:/sbin:/usr/ibm-java-ppc64-71/jre/bin:/usr/ibm-java-ppc64-71/bin:/elmec/node/bin
export JAVA_HOME=/usr/ibm-java-ppc64-71

但问题在于它会引发错误,如标题所示:

gyp verb node-gyp root Finding node root directory
gyp verb node-gyp root in build directory, root = /elmec/node/include/node
gyp verb node-gyp configure node.exp Checking: /elmec/node/include/node/out/Release/node.exp
gyp verb node-gyp configure node.exp Checking: /elmec/node/include/node/include/node/node.exp
gyp verb node-gyp configure node.exp Checking: /elmec/node/include/node/node.exp
gyp info node-gyp configure node.exp copying "node.exp" from /elmec/node/include/node/node.exp to /.node-gyp/0.12.7/node.exp
gyp verb build dir attempting to create "build" dir: /elmec/node_apps/node_modules/java/build
gyp verb build dir "build" dir needed to be created? /elmec/node_apps/node_modules/java/build
gyp verb build/config.gypi creating config file
gyp verb build/config.gypi writing out config file: /elmec/node_apps/node_modules/java/build/config.gypi
gyp verb config.gypi checking for gypi file: /elmec/node_apps/node_modules/java/config.gypi
gyp verb common.gypi checking for gypi file: /elmec/node_apps/node_modules/java/common.gypi
gyp verb gyp gyp format was not specified; forcing "make"
gyp info spawn python2
gyp info spawn args [ '/elmec/node/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
gyp info spawn args   'binding.gyp',
gyp info spawn args   '-f',
gyp info spawn args   'make',
gyp info spawn args   '-I',
gyp info spawn args   '/elmec/node_apps/node_modules/java/build/config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/elmec/node/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/.node-gyp/0.12.7/common.gypi',
gyp info spawn args   '-Dlibrary=shared_library',
gyp info spawn args   '-Dvisibility=default',
gyp info spawn args   '-Dnode_root_dir=/.node-gyp/0.12.7',
gyp info spawn args   '-Dmodule_root_dir=/elmec/node_apps/node_modules/java',
gyp info spawn args   '--depth=.',
gyp info spawn args   '--no-parallel',
gyp info spawn args   '--generator-output',
gyp info spawn args   'build',
gyp info spawn args   '-Goutput_dir=.' ]
gyp verb command build []
gyp verb build type Release
gyp verb architecture ppc64
gyp verb node dev dir /.node-gyp/0.12.7
gyp verb `which` succeeded for `gmake` /usr/bin/gmake
gyp info spawn gmake
gyp info spawn args [ 'V=1', 'BUILDTYPE=Release', '-C', 'build' ]
gmake: Entering directory '/elmec/node_apps/node_modules/java/build'
  g++ '-DNODE_GYP_MODULE_NAME=nodejavabridge_bindings' '-D_LARGEFILE_SOURCE' '-D_FILE_OFFSET_BITS=64' '-D__LITTLE_ENDIAN=1234' '-D__BIG_ENDIAN=4321' '-D__BYTE_ORDER=__BIG_ENDIAN' '-D__FLOAT_WORD_ORDER=__BIG_ENDIAN' '-DBUILDING_NODE_EXTENSION' -I/.node-gyp/0.12.7/src -I/.node-gyp/0.12.7/deps/uv/include -I/.node-gyp/0.12.7/deps/v8/include -I/usr/ibm-java-ppc64-71/include -I../node_modules/nan  -pthread -Wall -Wextra -Wno-unused-parameter -maix64 -O3 -O3 -ffunction-sections -fdata-sections -fno-tree-vrp -fno-omit-frame-pointer -fno-rtti -fno-exceptions -MMD -MF ./Release/.deps/Release/obj.target/nodejavabridge_bindings/src/java.o.d.raw  -c -o Release/obj.target/nodejavabridge_bindings/src/java.o ../src/java.cpp
  g++ '-DNODE_GYP_MODULE_NAME=nodejavabridge_bindings' '-D_LARGEFILE_SOURCE' '-D_FILE_OFFSET_BITS=64' '-D__LITTLE_ENDIAN=1234' '-D__BIG_ENDIAN=4321' '-D__BYTE_ORDER=__BIG_ENDIAN' '-D__FLOAT_WORD_ORDER=__BIG_ENDIAN' '-DBUILDING_NODE_EXTENSION' -I/.node-gyp/0.12.7/src -I/.node-gyp/0.12.7/deps/uv/include -I/.node-gyp/0.12.7/deps/v8/include -I/usr/ibm-java-ppc64-71/include -I../node_modules/nan  -pthread -Wall -Wextra -Wno-unused-parameter -maix64 -O3 -O3 -ffunction-sections -fdata-sections -fno-tree-vrp -fno-omit-frame-pointer -fno-rtti -fno-exceptions -MMD -MF ./Release/.deps/Release/obj.target/nodejavabridge_bindings/src/javaObject.o.d.raw  -c -o Release/obj.target/nodejavabridge_bindings/src/javaObject.o ../src/javaObject.cpp
  g++ '-DNODE_GYP_MODULE_NAME=nodejavabridge_bindings' '-D_LARGEFILE_SOURCE' '-D_FILE_OFFSET_BITS=64' '-D__LITTLE_ENDIAN=1234' '-D__BIG_ENDIAN=4321' '-D__BYTE_ORDER=__BIG_ENDIAN' '-D__FLOAT_WORD_ORDER=__BIG_ENDIAN' '-DBUILDING_NODE_EXTENSION' -I/.node-gyp/0.12.7/src -I/.node-gyp/0.12.7/deps/uv/include -I/.node-gyp/0.12.7/deps/v8/include -I/usr/ibm-java-ppc64-71/include -I../node_modules/nan  -pthread -Wall -Wextra -Wno-unused-parameter -maix64 -O3 -O3 -ffunction-sections -fdata-sections -fno-tree-vrp -fno-omit-frame-pointer -fno-rtti -fno-exceptions -MMD -MF ./Release/.deps/Release/obj.target/nodejavabridge_bindings/src/javaScope.o.d.raw  -c -o Release/obj.target/nodejavabridge_bindings/src/javaScope.o ../src/javaScope.cpp
  g++ '-DNODE_GYP_MODULE_NAME=nodejavabridge_bindings' '-D_LARGEFILE_SOURCE' '-D_FILE_OFFSET_BITS=64' '-D__LITTLE_ENDIAN=1234' '-D__BIG_ENDIAN=4321' '-D__BYTE_ORDER=__BIG_ENDIAN' '-D__FLOAT_WORD_ORDER=__BIG_ENDIAN' '-DBUILDING_NODE_EXTENSION' -I/.node-gyp/0.12.7/src -I/.node-gyp/0.12.7/deps/uv/include -I/.node-gyp/0.12.7/deps/v8/include -I/usr/ibm-java-ppc64-71/include -I../node_modules/nan  -pthread -Wall -Wextra -Wno-unused-parameter -maix64 -O3 -O3 -ffunction-sections -fdata-sections -fno-tree-vrp -fno-omit-frame-pointer -fno-rtti -fno-exceptions -MMD -MF ./Release/.deps/Release/obj.target/nodejavabridge_bindings/src/methodCallBaton.o.d.raw  -c -o Release/obj.target/nodejavabridge_bindings/src/methodCallBaton.o ../src/methodCallBaton.cpp
  g++ '-DNODE_GYP_MODULE_NAME=nodejavabridge_bindings' '-D_LARGEFILE_SOURCE' '-D_FILE_OFFSET_BITS=64' '-D__LITTLE_ENDIAN=1234' '-D__BIG_ENDIAN=4321' '-D__BYTE_ORDER=__BIG_ENDIAN' '-D__FLOAT_WORD_ORDER=__BIG_ENDIAN' '-DBUILDING_NODE_EXTENSION' -I/.node-gyp/0.12.7/src -I/.node-gyp/0.12.7/deps/uv/include -I/.node-gyp/0.12.7/deps/v8/include -I/usr/ibm-java-ppc64-71/include -I../node_modules/nan  -pthread -Wall -Wextra -Wno-unused-parameter -maix64 -O3 -O3 -ffunction-sections -fdata-sections -fno-tree-vrp -fno-omit-frame-pointer -fno-rtti -fno-exceptions -MMD -MF ./Release/.deps/Release/obj.target/nodejavabridge_bindings/src/nodeJavaBridge.o.d.raw  -c -o Release/obj.target/nodejavabridge_bindings/src/nodeJavaBridge.o ../src/nodeJavaBridge.cpp
  g++ '-DNODE_GYP_MODULE_NAME=nodejavabridge_bindings' '-D_LARGEFILE_SOURCE' '-D_FILE_OFFSET_BITS=64' '-D__LITTLE_ENDIAN=1234' '-D__BIG_ENDIAN=4321' '-D__BYTE_ORDER=__BIG_ENDIAN' '-D__FLOAT_WORD_ORDER=__BIG_ENDIAN' '-DBUILDING_NODE_EXTENSION' -I/.node-gyp/0.12.7/src -I/.node-gyp/0.12.7/deps/uv/include -I/.node-gyp/0.12.7/deps/v8/include -I/usr/ibm-java-ppc64-71/include -I../node_modules/nan  -pthread -Wall -Wextra -Wno-unused-parameter -maix64 -O3 -O3 -ffunction-sections -fdata-sections -fno-tree-vrp -fno-omit-frame-pointer -fno-rtti -fno-exceptions -MMD -MF ./Release/.deps/Release/obj.target/nodejavabridge_bindings/src/utils.o.d.raw  -c -o Release/obj.target/nodejavabridge_bindings/src/utils.o ../src/utils.cpp
  g++ -Wl,-bM:sre -Wl,-bnoentry -Wl,-bexpfull -shared -Wl,-bimport:/.node-gyp/0.12.7/node.exp -pthread -maix64  -o Release/obj.target/nodejavabridge_bindings.node Release/obj.target/nodejavabridge_bindings/src/java.o Release/obj.target/nodejavabridge_bindings/src/javaObject.o Release/obj.target/nodejavabridge_bindings/src/javaScope.o Release/obj.target/nodejavabridge_bindings/src/methodCallBaton.o Release/obj.target/nodejavabridge_bindings/src/nodeJavaBridge.o Release/obj.target/nodejavabridge_bindings/src/utils.o
ld: 0711-317 ERROR: Undefined symbol: .JNI_GetDefaultJavaVMInitArgs
ld: 0711-317 ERROR: Undefined symbol: .JNI_CreateJavaVM
ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information.
collect2: error: ld returned 8 exit status
nodejavabridge_bindings.target.mk:132: recipe for target 'Release/obj.target/nodejavabridge_bindings.node' failed
gmake: *** [Release/obj.target/nodejavabridge_bindings.node] Error 1
gmake: Leaving directory '/elmec/node_apps/node_modules/java/build'
gyp ERR! build error
gyp ERR! stack Error: `gmake` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/elmec/node/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:270:23)
gyp ERR! stack     at ChildProcess.emit (events.js:110:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:1074:12)
gyp ERR! System AIX 1
gyp ERR! command "node" "/elmec/node/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /elmec/node_apps/node_modules/java
gyp ERR! node -v v0.12.7
gyp ERR! node-gyp -v v2.0.1
gyp ERR! not ok
npm verb unsafe-perm in lifecycle false
npm info java@0.5.4 Failed to exec install script
npm verb unlock done using /.npm/_locks/java-4a9b752fb6bea515.lock for /elmec/node_apps/node_modules/java
npm verb stack Error: java@0.5.4 install: `node-gyp rebuild`
npm verb stack Exit status 1
npm verb stack     at EventEmitter.<anonymous> (/elmec/node/lib/node_modules/npm/lib/utils/lifecycle.js:213:16)
npm verb stack     at EventEmitter.emit (events.js:110:17)
npm verb stack     at ChildProcess.<anonymous> (/elmec/node/lib/node_modules/npm/lib/utils/spawn.js:24:14)
npm verb stack     at ChildProcess.emit (events.js:110:17)
npm verb stack     at maybeClose (child_process.js:1015:16)
npm verb stack     at Process.ChildProcess._handle.onexit (child_process.js:1087:5)
npm verb pkgid java@0.5.4
npm verb cwd /elmec/node_apps
npm ERR! AIX 1
npm ERR! argv "/elmec/node/bin/node" "/elmec/node/bin/npm" "install" "--verbose" "java" "--javahome=/usr/ibm-java-ppc64-71"
npm ERR! node v0.12.7
npm ERR! npm  v2.11.3
npm ERR! code ELIFECYCLE

npm ERR! java@0.5.4 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the java@0.5.4 install script 'node-gyp rebuild'.
npm ERR! This is most likely a problem with the java package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp rebuild
npm ERR! You can get their info via:
npm ERR!     npm owner ls java
npm ERR! There is likely additional logging output above.
npm verb exit [ 1, true ]
npm verb unbuild node_modules/java
npm info preuninstall java@0.5.4
npm info uninstall java@0.5.4
npm verb unbuild rmStuff java@0.5.4 from /elmec/node_apps/node_modules
npm info postuninstall java@0.5.4
npm verb gentlyRm don't care about contents; nuking /elmec/node_apps/node_modules/java

npm ERR! Please include the following file with any support request:
npm ERR!     /elmec/node_apps/npm-debug.log

这是JAVA目录结构 here

EDIT1: @ankhzet 如果我把我的JAVA_HOME指向/ bin,我会收到另一个错误:

gyp verb `which` succeeded for `gmake` /usr/bin/gmake
gyp info spawn gmake
gypgmake: Entering directory '/elmec/node_apps/node_modules/jt400/node_modules/java/build'
 info spawn args [ 'V=1', 'BUILDTYPE=Release', '-C', 'build' ]
  g++ '-DNODE_GYP_MODULE_NAME=nodejavabridge_bindings' '-D_LARGEFILE_SOURCE' '-D_FILE_OFFSET_BITS=64' '-D__LITTLE_ENDIAN=1234' '-D__BIG_ENDIAN=4321' '-D__BYTE_ORDER=__BIG_ENDIAN' '-D__FLOAT_WORD_ORDER=__BIG_ENDIAN' '-DBUILDING_NODE_EXTENSION' -I/.node-gyp/0.12.7/src -I/.node-gyp/0.12.7/deps/uv/include -I/.node-gyp/0.12.7/deps/v8/include -I/usr/java5/jre/include -I../node_modules/nan  -pthread -Wall -Wextra -Wno-unused-parameter -maix64 -O3 -O3 -ffunction-sections -fdata-sections -fno-tree-vrp -fno-omit-frame-pointer -fno-rtti -fno-exceptions -MMD -MF ./Release/.deps/Release/obj.target/nodejavabridge_bindings/src/java.o.d.raw  -c -o Release/obj.target/nodejavabridge_bindings/src/java.o ../src/java.cpp
In file included from ../src/java.cpp:1:0:
../src/java.h:7:17: fatal error: jni.h: No such file or directory
 #include <jni.h>

EDIT2: @ZsigmondLőrinczy

抱歉,但我无法理解你要我做什么。我可以向你指出npm包的回购: enter image description here

EDIT3: 我使用从FixCentral下载的最新修补程序更新了我的IBM JDK。我在想系统缺少libjvm.so 我试图将库的位置添加到LIBPATH和LD_LIBRARY_PATH,但它仍然无法正常工作。

export LIBPATH=/usr/lib:/opt/freeware/lib64:/usr/ibm-java-ppc64-71/jre/bin:/usr/ibm-java-ppc64-71/jre/bin/classic:/usr/ibm-java-ppc64-71/include:/usr/ibm-java-ppc64-71/jre/lib/ppc64/classic:/usr/ibm-java-ppc64-71/include/aix
export LD_LIBRARY_PATH=$LIBPATH

EDIT4: 我刚刚运行nm -X64 /usr/ibm-java-ppc64-71/jre/bin/classic/libjvm.so,这是输出(你可以看到它包含2个符号) https://github.com/joeferner/node-java

事实是libjvm.so即使在路径/usr/ibm-java-ppc64-71/jre/bin/j9vm/libjvm.so

也存在

无论好坏,libjvm.so出现在所有这些路径中: enter image description here

0 个答案:

没有答案