没有合适的资源?快使用搜索试试~ 我知道了~
jni需要注意的常见问题
需积分: 10 15 下载量 201 浏览量
2011-12-13
17:13:47
上传
评论 1
收藏 3KB TXT 举报
温馨提示
试读
2页
jni 输入的问题; 找不到相应的库文件链接的问题java.lang.UnsatisfiedLinkError: no testjni1 in java.library.path ;Linux下编译下找不到库文件符号的问题libXXX.so: undefined symbol: _ZdlPv
资源推荐
资源详情
资源评论
最近学习了jni,总结一些心得体验,希望给大家有点帮助。在学习jni的过程中,遇到一些常见的问题。在这里就不再谈及怎样调用jni的步骤,网上查找即可,在此推荐一篇写的调用很全的文章:http://netcome.iteye.com/blog/monthblog/2010-06?show_full=true
下面是我在编写过程中遇到的问题:
1.输入的问题:C/C++语言的.c或者.c++的文件一定要尽量手打输入,这样可以避免格式上输入的错误。例如:
testjni.cpp:10: error: stray ‘\240’ in program
testjni.cpp:10: error: stray ‘\302’ in program
testjni.cpp:10: error: stray ‘\240’ in program
testjni.cpp:14: error: stray ‘\302’ in program
testjni.cpp:14: error: stray ‘\240’ in program
testjni.cpp:14: error: stray ‘\302’ in program
testjni.cpp:14: error: stray ‘\240’ in program
testjni.cpp:16: error: stray ‘\302’ in program
testjni.cpp:16: error: stray ‘\302’ in program
testjni.cpp:16: error: stray ‘\302’ in program
testjni.cpp:16: error: stray ‘\302’ in program
这就是一个很明显由于从网页上复制下来粘贴而引起的空格与linux下的space键不同的问题,最好自己手动输入,或者替换,替换不一定好。在写native函数的时候最好也从相对应的.h文件复制函数名与参数。
2. 找不到相应的库文件链接的问题,如:
Exception in thread "main" java.lang.UnsatisfiedLinkError: no testjni1 in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1738)
at java.lang.Runtime.loadLibrary0(Runtime.java:823)
at java.lang.System.loadLibrary(System.java:1028)
at Weiwei.<clinit>(Weiwei.java:9)
Could not find the main class: Weiwei. Program will exit.
临时解决的办法:
a.设置export LD_LIBRARY_PATH=./ 即可,在输出就可以的了
b.java -Djava.library.path=. -cp . 类名
c.可以调用System.out.print(System.getProperty("java.library.path")); 来查看! 然后把libXXXX.so(windows环境将.dll文件)拷贝到那里面的目录下去
3.Linux下编译下找不到库文件符号的问题:libXXX.so: undefined symbol: _ZdlPv
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
下面是我在编写过程中遇到的问题:
1.输入的问题:C/C++语言的.c或者.c++的文件一定要尽量手打输入,这样可以避免格式上输入的错误。例如:
testjni.cpp:10: error: stray ‘\240’ in program
testjni.cpp:10: error: stray ‘\302’ in program
testjni.cpp:10: error: stray ‘\240’ in program
testjni.cpp:14: error: stray ‘\302’ in program
testjni.cpp:14: error: stray ‘\240’ in program
testjni.cpp:14: error: stray ‘\302’ in program
testjni.cpp:14: error: stray ‘\240’ in program
testjni.cpp:16: error: stray ‘\302’ in program
testjni.cpp:16: error: stray ‘\302’ in program
testjni.cpp:16: error: stray ‘\302’ in program
testjni.cpp:16: error: stray ‘\302’ in program
这就是一个很明显由于从网页上复制下来粘贴而引起的空格与linux下的space键不同的问题,最好自己手动输入,或者替换,替换不一定好。在写native函数的时候最好也从相对应的.h文件复制函数名与参数。
2. 找不到相应的库文件链接的问题,如:
Exception in thread "main" java.lang.UnsatisfiedLinkError: no testjni1 in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1738)
at java.lang.Runtime.loadLibrary0(Runtime.java:823)
at java.lang.System.loadLibrary(System.java:1028)
at Weiwei.<clinit>(Weiwei.java:9)
Could not find the main class: Weiwei. Program will exit.
临时解决的办法:
a.设置export LD_LIBRARY_PATH=./ 即可,在输出就可以的了
b.java -Djava.library.path=. -cp . 类名
c.可以调用System.out.print(System.getProperty("java.library.path")); 来查看! 然后把libXXXX.so(windows环境将.dll文件)拷贝到那里面的目录下去
3.Linux下编译下找不到库文件符号的问题:libXXX.so: undefined symbol: _ZdlPv
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
资源评论
wuyue_qiushui
- 粉丝: 0
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功