如何交叉编译包含JNI的C代码?

时间:2016-02-26 06:21:08

标签: java c shared-libraries cross-compiling

以前我问了一个与调用java函数有关的问题

Calling Java functions from C language

不知何故,我做到了。 现在我打算交叉编译。

我正面临一个问题。 在交叉编译之前(意味着在同一台PC上为同一台PC编译) 我使用了命令

gcc -I /usr/lib/jvm/java-6-openjdk-amd64/include  -I /usr/lib/jvm/java-6-openjdk-amd64/include/linux -L /usr/bin/java -L /usr/lib/jvm/java-6-openjdk-amd64/jre/lib/amd64/server  MyC.c -ljvm ;

创造得很好。 但是现在我正试图为我的目标arm-none-eabi-

交叉编译

我的makefile

CROSS_COMPILE =arm-none-eabi-
JAVA_HOME =/usr/lib/jvm/java-7-openjdk-amd64/
test:
    javac -d ./ MyJava.java
    $(CROSS_COMPILE)gcc -I $(JAVA_HOME)include \
            -I $(JAVA_HOME)include/linux \
            -L $(JAVA_HOME)jre/lib/amd64/server \
             MyC.c -ljvm

此返回错误

arm-none-eabi/bin/ld: warning: library search path "/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/amd64/server" is unsafe for cross-compilation
/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/amd64/server/libjvm.so: file not recognized: File format not recognized
collect2: ld returned 1 exit status
make: *** [test] Error 1

0 个答案:

没有答案