| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1628 人关注过本帖
标题:再请高手赐教:wrong ELF class: ELFCLASS64,十分感谢
取消只看楼主 加入收藏
pheobus
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2007-3-7
收藏
 问题点数:0 回复次数:1 
再请高手赐教: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
pheobus
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2007-3-7
收藏
得分:0 
是编译方法有问题,还是什么原因呢?
2007-03-07 16:28
快速回复:再请高手赐教:wrong ELF class: ELFCLASS64,十分感谢
数据加载中...
 
   



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

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