标题:再请高手赐教:wrong ELF class: ELFCLASS64,十分感谢
只看楼主
pheobus
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2007-3-7
 问题点数:0 回复次数:3 
再请高手赐教:wrong ELF class: ELFCLASS64,十分感谢
编译.so库时若不用-fPIC,会编不过有错误如下:
linux-z03057:~/workspace/CtoJavaTest # g++ -I/home/z03057/src/jdk1.6.0/include -I/home/z03057/src/jdk1.6.0/include/linux -o testdll.so -shared GetPid.c
/usr/lib64/gcc/x86_64-suse-linux/4.1.0/../../../../x86_64-suse-linux/bin/ld: /tmp/ccq6CLL8.o: relocation R_X86_64_32 against `__gxx_personality_v0' can not be used when making a shared object; recompile with -fPIC
/tmp/ccq6CLL8.o: could not read symbols: Bad value
collect2: ld returned 1 exit status
linux-z03057:~/workspace/CtoJavaTest #
linux-z03057:~/workspace/CtoJavaTest # javac GetPid.java
linux-z03057:~/workspace/CtoJavaTest # g++ -I/home/z03057/src/jdk1.6.0/include -I/home/z03057/src/jdk1.6.0/include/linux -w -fPIC -DPIC -o testdll.so -shared GetPid.c

运行时,出现以下错误:
linux-z03057:~/workspace/CtoJavaTest # java GetPid
/home/z03057/src/jdk1.6.0/jre/lib/i386/client:/home/z03057/src/jdk1.6.0/jre/lib/i386:/home/z03057/src/jdk1.6.0/jre/../lib/i386:.:/home/z03057/src/jdk1.6.0/jre/l ib/i386/client:/home/z03057/src/jdk1.6.0/jre/lib/i386:/lib:/usr/lib:/usr/java/packages/lib/i386:/lib:/usr/lib
Exception in thread "main" java.lang.UnsatisfiedLinkError: /root/workspace/CtoJavaTest/testdll.so: /root/workspace/CtoJavaTest/testdll.so: wrong ELF class: ELFCLASS64
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1751)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1676)
at java.lang.Runtime.loadLibrary0(Runtime.java:823)
at java.lang.System.loadLibrary(System.java:1030)
at GetPid.<clinit>(GetPid.java:5)
搜索更多相关主题的帖子: ELF wrong class 
2007-03-07 16:09
千里冰封
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:灌水之王
等 级:版主
威 望:155
帖 子:28477
专家分:59
注 册:2006-2-26
得分:0 

都是因你没有生成好SO文件


可惜不是你,陪我到最后
2007-03-07 16:13
pheobus
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2007-3-7
得分:0 
是编译方法有问题,还是什么原因呢?
2007-03-07 16:28
千里冰封
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:灌水之王
等 级:版主
威 望:155
帖 子:28477
专家分:59
注 册:2006-2-26
得分:0 
不好意思,对于C,我不了解

可惜不是你,陪我到最后
2007-03-07 16:30



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-122920-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.319078 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved