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


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


    如果编译时,报如下所示错误:
    ../../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.


    再次执行,一切正常,需要升级GCC了,或者降低JRE或JDK的版本试试:
    ./nm libjvm.so | grep JNI_CreateJavaVM
    00000000006307c0 T JNI_CreateJavaVM
  • 相关阅读:
    Runtime Type Information 运行时类型信息RTTI
    ADO实现单条记录的刷新
    TDataLink类说明
    编程实现文件关联
    咏南的连接池
    关系数据库系统PK面向对象数据库系统
    div+CSS编程技巧
    Hadoop编程笔记(一):Mapper及Reducer类详解
    如何统计博客园的个人博客访问量
    MapReduce编程模型:用MapReduce进行大数据分析
  • 原文地址:https://www.cnblogs.com/aquester/p/9891603.html
Copyright © 2020-2023  润新知