“undefined JNI_GetCreatedJavaVM”和“File format not recognized”错误原因分析

简介: 如果编译时,报如下所示错误: ../../third-party/hadoop/lib/libhdfs.a(jni_helper.c.o): In function `getGlobalJNIEnv': /root/hadoop-2.
如果编译时,报如下所示错误:
../../third-party/hadoop/lib/libhdfs.a(jni_helper.c.o): In function `getGlobalJNIEnv':
/root/hadoop-2.4.0-src/hadoop-hdfs-project/hadoop-hdfs/src/main/native/libhdfs/jni_helper.c:446: undefined reference to `JNI_GetCreatedJavaVMs'
/root/hadoop-2.4.0-src/hadoop-hdfs-project/hadoop-hdfs/src/main/native/libhdfs/jni_helper.c:505: undefined reference to `JNI_CreateJavaVM'
/root/hadoop-2.4.0-src/hadoop-hdfs-project/hadoop-hdfs/src/main/native/libhdfs/jni_helper.c:505: undefined reference to `JNI_CreateJavaVM'


是因为链接时,没有加上库文件libjvm.so。加上libjvm.so重编译,如果又遇到如下所示的错误:
../../third-party/libjvm.so: file not recognized: File format not recognized


这问题是因为libjvm.so不能被识别,libjvm.so的版本过高导致的
nm ../../third-party/libjvm.so | grep JNI_CreateJavaVM
nm: ../../third-party/libjvm.so: 不可识别的文件格式


查看nm的版本:
nm --version
GNU nm 2.16.91.0.5 20051219 (SUSE Linux)
Copyright 2005 Free Software Foundation, Inc.
本程序是自由软件;您可以按照 GNU 通用公共许可证
的条款对其进行再发行。本程序没有任何担保。


现在换成高一点的版本试试:
./nm --version
GNU nm 2.17.50.0.6-20.el5 20061020
Copyright 2005 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License.  This program has absolutely no warranty.


再次执行,一切正常,需要升级 ld了,或者降低JRE或JDK的版本试试:
./nm libjvm.so | grep JNI_CreateJavaVM
00000000006307c0 T JNI_CreateJavaVM

实际应用中,编译虽然存在此问题,但运行时,可以使用更高版本的libjvm.so。

ld下载地址: http://ftp.gnu.org/gnu/binutils/(ld 和nm均是GNU binutils的成员之一)。

相关文章
|
分布式计算 Java Hadoop
“undefined reference to JNI_GetCreatedJavaVM”和“File format not recognized”错误原因分析
“undefined reference to JNI_GetCreatedJavaVM”和“File format not recognized”错误原因分析 如果编译时,报如下所示错误: .
1063 0
|
5月前
|
前端开发 小程序 JavaScript
微信小程序-Unhandled promise rejection TypeError: Cannot read property ‘get‘ of undefined
微信小程序-Unhandled promise rejection TypeError: Cannot read property ‘get‘ of undefined
|
3月前
|
存储 JavaScript 前端开发
成功解决:Cannot read properties of undefined (reading ‘commit‘)
这篇文章提供了解决Vuex中"Cannot read properties of undefined (reading 'commit')"错误的两种方法:检查模板中的数据属性是否存在,以及确保在Vue实例中正确挂载了store对象。
成功解决:Cannot read properties of undefined (reading ‘commit‘)
|
3月前
|
定位技术 Apache
Echarts——Invalid geoJson format Cannot read property 'length' of undefined
Echarts——Invalid geoJson format Cannot read property 'length' of undefined
87 0
|
3月前
|
JavaScript
VUE——filemanager-webpack-plugin报错TypeError: Cannot read property 'isFile' of undefined
VUE——filemanager-webpack-plugin报错TypeError: Cannot read property 'isFile' of undefined
74 0
|
3月前
|
前端开发 JavaScript
VUE——Uncaught (in promise) TypeError: Cannot read property '__esModule' of undefined
VUE——Uncaught (in promise) TypeError: Cannot read property '__esModule' of undefined
71 0
TypeError: Cannot set properties of undefined (setting ‘resdata‘),res定义数据出现的问题,定义的方法用this换成that
TypeError: Cannot set properties of undefined (setting ‘resdata‘),res定义数据出现的问题,定义的方法用this换成that
Cannot read properties of undefined (reading ‘row‘)
Cannot read properties of undefined (reading ‘row‘)
Cannot read properties of undefined (reading ‘post‘)
Cannot read properties of undefined (reading ‘post‘)
|
4月前
|
JavaScript
element-ui Cannot read properties of undefined (reading ‘name‘),data中写成集合的形式
element-ui Cannot read properties of undefined (reading ‘name‘),data中写成集合的形式