java - "Swig to java (Android)": giving No such file or directory Error on generating Swig to Java file

标签 java android java-native-interface swig

我是 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/

相关文章:

java - 如何在当前位置的 EditText 中添加可点击的小部件

java - 在 java swing 中创建可扩展的方格边距

java - Android NullPointerException 和 GetDatabaseLocked

android - ListView中滚动时调用哪个函数

java - 尝试使用 javapns 向 Apple 推送通知服务发送通知

java - 为什么我的 updateAppWidget 方法不对所有操作使用react?

android - Android 上的 Ruby 处理

java - Android 无法找到我的 JNI native 库函数

java - jni/java : thread safe publishing/sharing of effectively immutable native object

java - 无法使用JNI从C++中的jar访问某些类