当前位置: 代码迷 >> Java相关 >> 再请高手赐教:wrong ELF class: ELFCLASS64,十分感谢
  详细解决方案

再请高手赐教:wrong ELF class: ELFCLASS64,十分感谢

热度:603   发布时间:2007-03-07 16:09:00.0
再请高手赐教: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  

----------------解决方案--------------------------------------------------------

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


----------------解决方案--------------------------------------------------------
是编译方法有问题,还是什么原因呢?
----------------解决方案--------------------------------------------------------
不好意思,对于C,我不了解

----------------解决方案--------------------------------------------------------
  相关解决方案