以下是很简单的一个官方的jni方法,在MainActivity的onCreate中调用

extern "C" JNIEXPORT jstring JNICALL
Java_com_example_openclplayground_MainActivity_stringFromJNI(
JNIEnv* env,
jobject /* this */) {
auto cl_handle = dlopen("/system/vendor/lib64/libOpenCL.so",RTLD_LAZY);
__android_log_print(ANDROID_LOG_DEBUG,"sxf","dl result2 is:%s",dlerror()); }

发现每次把app进程杀死,重进进入,这个dlerror都会打印“undefined symbol: JNI_OnLoad”

如果把同样的dlopen方法放到电脑上编译运行,肯定是没有error的,而且报错的字段中有JNI的TAG,可见这个错误是跟android有关的。

又因为dlerror的官方解释

The dlerror() function returns a human-readable, null-terminated
string describing the most recent error that occurred from a call
to one of the functions in the dlopen API since the last call to
dlerror(). The returned string does not include a trailing
newline.

可见dlerror报的错误是从上一个dlerror到这次dlerror,发生的最后一次error的信息。

所以把程序稍微改一改,改成这样

extern "C" JNIEXPORT jstring JNICALL
Java_com_example_openclplayground_MainActivity_stringFromJNI(
JNIEnv* env,
jobject /* this */) {
__android_log_print(ANDROID_LOG_DEBUG,"sxf","dl result2 is:%s",dlerror());
auto cl_handle = dlopen("/system/vendor/lib64/libOpenCL.so",RTLD_LAZY); }

可以看到仍然会报错“undefined symbol: JNI_OnLoad”

所以其实我们的dlopen并没有发生错误,是android系统自己dlopen某些奇怪的东西报了错,然后它又没有用dlerror清空,导致我们一开始dlopen然后再dlerror就得到了一个android 系统的dlerror。

解决方案

1、无视该错误。

2、调用dlopen前先调用一次dlerror

google有点坑啊...

												

android jni-dlerror报undefined symbol: JNI_OnLoad的更多相关文章

  1. 微信SDK接入报undefined symbol错误

    按照官方SDK接入 编译后报如下错误 是因为没有link libc++库导致的.

  2. Linux下Python3.5使用pyqt5.11报错 ImportError: /usr/local/lib/python3.5/dist-packages/PyQt5/QtCore.so: undefined symbol: PySlice_AdjustIndices 解决方法

    我用的Linux自带的是Python3.5版本,运行pip3 install PyQt5, 下载的是PyQt5.11,运行PyQt5程序会报错: ImportError: /usr/local/lib ...

  3. ADS报错 Warning : L6301W:Could not find file C:\Program Files . Error : L6218 : Undefined symbol ......

    ADS1.2编译时,出现找不到一个不存在目录下的目标文件(*.o) 编译一个COPY到硬盘上的一个工程,出现以下的fatal error message: Error: (Fatal)L6002: C ...

  4. fastDfs V5.02 升级到 V5.08版本后,启动报错:symbol lookup error: /usr/bin/fdfs_trackerd: undefined symbol: g_current_time

    /libfastcommon-1.0.36 # ./make.sh cc -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -g -O3 -c -o hash.o ...

  5. JNI调用Cython生成库‘undefined symbol: PyInit_’问题

    最近项目需要提升所有 Python 算法的执行时间,并给 Java 框架调用,根据 Python一键转Jar包,Java调用Python新姿势!的思路可以用 Cython 将 Python 代码转换为 ...

  6. 执行dlsym()函数出现: undefined symbol

    执行dlsym()函数出现: undefined symbol 执行dlsym()函数出现: undefined symbol 当这个问题出现的时候,可以检查产生so文件的cpp文件,看看是否已经用  ...

  7. [转载]—— Android JNI知识点

    Java Native Interface (JNI)标准是java平台的一部分,它允许Java代码和其他语言写的代码进行交互.JNI 是本地编程接口,它使得在 Java 虚拟机 (VM) 内部运行的 ...

  8. 【转】android JNI

    原文网址:http://jinguo.iteye.com/blog/696185 Java Native Interface (JNI)标准是java平台的一部分,它允许Java代码和其他语言写的代码 ...

  9. Android JNI学习(三)——Java与Native相互调用

    本系列文章如下: Android JNI(一)——NDK与JNI基础 Android JNI学习(二)——实战JNI之“hello world” Android JNI学习(三)——Java与Nati ...

随机推荐

  1. 《重学Java高并发》Sempahore的使用场景与常见误区

    大家好,我是威哥,<RocketMQ技术内幕>一书作者,荣获RocketMQ官方社区优秀布道师.CSDN2020博客执之星Top2等荣誉称号.目前担任中通快递技术平台部资深架构师,主要负责 ...

  2. AtCoder Beginner Contest 188题解

    A 题意 问\(x,y\)相差是否小于\(3\) #include<iostream> #include<cstdio> #include<cmath> #defi ...

  3. 一款真正可以拿的出手的本土嵌入式RTOS-SylixOS

    由 winniewei 提交于 周四, 12/20/2018 作者:张国斌 在参加工信部人才交流中心和南京浦口区开发区管委会联合举办的第三届集成电路产业紧缺人才创新发展高级研修班暨产业促进交流会期间, ...

  4. binlog真的是银弹吗?有些时候也让人头疼

    大家好,我是架构摆渡人.这是实践经验系列的第三篇文章,这个系列会给大家分享很多在实际工作中有用的经验,如果有收获,还请分享给更多的朋友. binlog 用于记录用户对数据库操作的SQL语句信息,同时主 ...

  5. Shell 打印空行的行号

    目录 Shell 打印空行的行号 题解 Shell 打印空行的行号 写一个 bash脚本以输出一个文本文件 nowcoder.txt中空行的行号,可能连续,从1开始 示例: 假设 nowcoder.t ...

  6. BIO/NIO/AIO对比

    IO 模型 就是使用什么样的通道进行数据的发送和接收,很大程度上决定了程序通信的性能. Java 支持三种网络编程模型:BIO.NIO.AIO. Java BIO,同步并阻塞(传统阻塞型),服务器实现 ...

  7. A Child's History of England.28

    By such means, and by taxing and oppressing the English people in every possible way, the Red King b ...

  8. flink04 -----1 kafkaSource 2. kafkaSource的偏移量的存储位置 3 将kafka中的数据写入redis中去 4 将kafka中的数据写入mysql中去

    1. kafkaSource 见官方文档 2. kafkaSource的偏移量的存储位置 默认存在kafka的特殊topic中,但也可以设置参数让其不存在kafka的特殊topic中   3   将k ...

  9. 【leetcode】212. Word Search II

    Given an m x n board of characters and a list of strings words, return all words on the board. Each ...

  10. Can we access global variable if there is a local variable with same name?

    In C, we cannot access a global variable if we have a local variable with same name, but it is possi ...