2017-04-04 2 views
0

Rpi2의 경우 기본 C 코드를 JNI으로 컴파일하려고합니다. 나는 rpi에서 GCC으로 직접 해보려고했습니다. 나는 많은 다른 스위치를 시도했다, 그러나 아무것도 작동하지 않습니다와 나는 아직도 점점 오전 :Raspberry Pi 2 용 JNI와 C 컴파일 (잘못된 ELF 클래스)

Java HotSpot(TM) Client VM warning: You have loaded library /tmp/libTestLibraryWrapper7702387558318276188.so which might have disabled stack guard. The VM will try to fix the stack guard now. 
It's highly recommended that you fix the library with 'execstack -c <libfile>', or link it with '-z noexecstack'. 
Exception in thread "main" java.lang.UnsatisfiedLinkError: 
/tmp/libTestLibraryWrapper7702387558318276188.so: 
/tmp/libTestLibraryWrapper7702387558318276188.so: 
wrong ELF class: ELFCLASS64 (Possible cause: architecture word width mismatch) 

내가 사용하고 :

gcc -shared -march=armv7-a -mfpu=neon-vfpv4 -mfloat-abi=hard -c -g -I/usr/lib/jvm/jdk-8-oracle-arm32-vfp-hflt/include/ -I/usr/lib/jvm/jdk-8-oracle-arm32-vfp-hflt/include/linux -fPIC -MMD -MP -MF "build/Debug/GNU-Linux/testJava.o.d" -o build/Debug/GNU-Linux/testJava.o testJava.c

내가 지금 힌트 그래서 어떤 종류 조금 붙어 감사하겠습니다.

+0

64 비트 공유 객체를 생성 한 것처럼 보입니다. 32 비트 JVM을 실행하는 경우 32 비트 공유 객체가 필요합니다. 'gcc -m32 ...'는 32 비트 공유 객체를 생성합니다. –

답변

0

당신은 여기에서 샘플을 사용해 볼 수 있습니다 :

http://jnicookbook.owsiak.org/recipe-No-001/

내가에서 문제없이 코드를 실행할 수 있어요

: 그냥

cat /proc/cpuinfo 
processor : 0 
model name : ARMv6-compatible processor rev 7 (v6l) 
BogoMIPS : 2.00 
Features : half thumb fastmult vfp edsp java tls 
CPU implementer : 0x41 
CPU architecture: 7 
CPU variant : 0x0 
CPU part : 0xb76 
CPU revision : 7 

Hardware : BCM2708 
Revision : 0010 
Serial  : 00000000ee4a3dc2 

다음을 수행하십시오

git clone https://github.com/mkowsiak/jnicookbook.git 
cd jnicookbook/recipeNo001/ 
export JAVA_HOME=$WHEREVER_YOUR_JAVA_IS 
make test 

결과를 알려주세요 :

make test 
/usr/lib/jvm/jdk-8-oracle-arm32-vfp-hflt/bin/java -Djava.library.path=:./lib -cp target recipeNo001.HelloWorld 
library: :./lib 
Hello world!