Previously wrote an Android NDK development Swig compiled JNI interface. Look at this article do not understand, look to see. C + + and Java Some language structure still have a certain difference, for example, C + + structure, some function return value is different, do swig compile to do some preprocessing, that is, configure the line. Here are a few things to talk about.
One, in general, string, array, enumeration type, etc. configuration unix.i
%module survey%include "std_string.i"%include "Arrays_java.i"%include "typemaps.i"%include "ENUMS.SWG"%{#include <src\posioffset.cpp>%}%include <src\PosiOffset.h>
<span style= "FONT-SIZE:14PX;" ><strong> Second, the calculation returns a double type configuration unix.i</strong></span>
<strong><span style= "FONT-SIZE:12PX;" >1, the first C + + CPosiOffset.h file configuration function now </span></strong>
<pre class= "html" name= "code" > #ifndef SWIG//Calculation results
BOOL GetOffset (double& dCx, double& dCy, double& dCh); #else///Calculation results
BOOL GetOffset (double& output, double& output, double& output); #endif//swig
<span style= "FONT-SIZE:12PX;" ><strong>2, in the corresponding C + + CPosiOffset.cpp file </strong></span>
<p>///calculates the result and obtains the offset acquisition coordinates bool Cposioffset::getoffset (double& dCx, double& dCy, double& dCh) {dcx= </ p><p> dcy= </p><p> dch= </p><p> return true;} </p><p> </p><strong><span style= "FONT-SIZE:12PX;" >3. The UNIX.I configuration is as follows </span></strong>
<p>%module survey%include "std_string.i"%include "Arrays_java.i"%include "typemaps.i"%include "ENUMS.SWG" < /p><p>%apply double& OUTPUT {double& result} //Add this sentence </p><p> </p><p>%{ </p><p> #include <src\cposioffset.cpp></p><p>%}</p><p>%include <src\ Cposioffset.h></p>
<strong><span style= "FONT-SIZE:14PX;" > above two general configuration application and android</span></strong>
<span style= "FONT-SIZE:12PX;" ><strong>1.Application</strong></span>
<p>app_abi: = Armeabi</p><p>app_stl: = stlport_static</p>
<span style= "FONT-SIZE:12PX;" ><strong>2.Android</strong></span>
<p>local_path: = $ (call My-dir) </p><p>include $ (clear_vars) </p><p>LOCAL_MODULE : = posiliblocal_src_files: = Unix_wrap.cxx</p><p>include $ (build_shared_library) </p> <p> </p><p><span style= "FONT-SIZE:14PX;" ><strong> three. Talk about the function return is the structure configuration </strong></span></p><p><strong><span style= " font-size:12px; " >1. In the CPosiOffset.h file configuration function </span></strong></p><p><strong><span style= " font-size:12px; " > above header file plus </span></strong></p><p> #ifndef _posi_offset_h_#define _posi_offset_h_</p ><p> #include "DefineStructure.h" #include "PosiOffset.h" </p><p> #ifdef swig%apply double& OUTPUT {double& Result}%feature ("director") Cposioffset; #endif </p><p>class cposioffset: {</p><p>......</p><p>}</p><p> </p><p><span style= "Font-size:12px; " ><strong>2. There is no need to deal with CPosiOffset.cpp. </strong></span></p><p><span style= "FONT-SIZE:12PX;" ><strong>3. In unix.i configure the following </strong></span></p><pre class= "html" name= "code" ><p>%module Survey< /p><p> </p><p> </p><p> </p><p>%include "Std_ STRING.I "%include" Arrays_java.i "%include" typemaps.i "%include" ENUMS.SWG " </p><p> </p ><p>%module (directors = 1) Unix//Add this sentence </p><p> </p><p>%{</p><p># Include <src\cposioffset.cpp></p><p>%}</p><p>%include <src\CPosiOffset.h> </p><p> </p><pre class= "html" name= "code" ><span style= "font-size:12px;" ><strong>4.application</strong></span>app_cflags + =-fexceptionsapp_stl: = gnustl_staticAPP_ Paltform: = android-9
<span style= "FONT-SIZE:12PX;" ><strong>5.Android</strong></span>
<p>local_path: = $ (call My-dir) </p><p>include $ (clear_vars) </p><p>local_module: = Posiliblocal_src_files: = unix_wrap.cxx</p><p>local_cpp_features + = Rtti</p><p>include $ ( Build_shared_library) </p>
To this end, specific some do not understand the meaning of the statement, you can copy to Baidu, in fact, there are many types of NDK development, there are different methods of compiling on the Internet. I introduce four without self-written package name What, are automatically compiled generated.
Today this blog editor do not know what the problem, add code snippets, will not be able to remove the pattern, so the layout is a bit ugly.
Android NDK Development Swig compiling JNI interface configuration file (ii)