我是 Swig 的新手,尝试使用 Swig 将基本 C 文件转换为 Java 接口(interface)。 我有一个 compute.i 文件:
%module compute
%inline %{
extern int gcd(int x, int y);
extern double Foo;
%}
和compute.c文件:
/* A global variable */
double Foo = 3.0;
/* Compute the greatest common divisor of positive integers */
int gcd(int x, int y) {
int g;
g = y;
while (x > 0) {
g = x;
x = y % x;
y = g;
}
return g;
}
还有一个带有基本 onCreateView 方法的 MainActivity
。我尝试使用以下命令生成 computeJNI.java:
swig -java -package com.example.swigbasicproject -outdir src/com/example/swigbasicproject/swig -o jni/compute_wrap.c jni/compute.i
但它给了我以下错误:
Unable to open file src/com/example/swigbasicproject/swig/computeJNI.java: No such file or directory
我错过了什么?
最佳答案
在运行 swig 命令之前,输出目录必须已经存在。
关于java - "Swig to java (Android)": giving No such file or directory Error on generating Swig to Java file,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33096846/