Swig

来自bbxwiki
跳转至: 导航搜索

Java用法

swig样例

  • 无头文件,直接函数申明方式
/* File : example.i */
%module example

%inline %{
extern int    gcd(int x, int y);
extern double Foo;
%}
  • 头文件方式
/* File : example.i */
%module example

%{
#include "example.h"
%}

/* Let's just grab the original header file here */
%include "example.h"

JNI-C++

# JNI env using C++ style
mkdir jsrc
swig -c++ -java -package com.bbxyard.test -outdir jsrc example.i
 
# JNI env using C Style
swig -java -package com.bbxyard.test -outdir jsrc example.i

命令行说明

Java Options (available with -java)
     -nopgcpp        - Suppress premature garbage collection prevention parameter
     -noproxy        - Generate the low-level functional interface instead
                       of proxy classes
     -oldvarnames    - old intermediary method names for variable wrappers
     -package <name> - set name of the Java package to <name>

Note: 'swig -<lang> -help' displays options for a specific target language.

参见