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>
Second, the calculation returns a double type configuration unix.i
1, first C + + CPosiOffset.h file configuration function now
#ifndef SWIG/ //Calculation result bool GetOffset (double& dCx, double& dCy, double& dCh), #else///Calculation result bool GetOffset ( double& output, double& output, double& output); #endif//swig
2, in the corresponding C + + CPosiOffset.cpp file
Calculate the result and get offset acquisition coordinates bool Cposioffset::getoffset (double& dCx, double& dCy, double& dCh) { dcx= dcy= dch= return true;}
3. The UNIX.I configuration is as follows
%module survey%include "std_string.i"%include "Arrays_java.i"%include "typemaps.i"%include "ENUMS.SWG"%apply double & OUTPUT {double& Result}//Add this sentence%{#include <src\posioffset.cpp>%}%include <src\PosiOffset.h>
Both of these common configurations application and Android
1.Application
App_abi: = Armeabiapp_stl: = stlport_static
2. Android
Local_path: = $ (call My-dir) include $ (clear_vars) local_module : = posiliblocal_src_files: = Unix_wrap.cxxinclude $ ( Build_shared_library)
Three. Talk about the function return is the structure configuration
1. In the CPosiOffset.h file configuration function
In the above header file plus
#ifndef _posi_offset_h_#define _posi_offset_h_#include "DefineStructure.h" #include "PosiOffset.h" #ifdef swig%apply double& OUTPUT {double& result}%feature ("director") Cposioffset; #endif
2. No handling in CPosiOffset.cpp
3. In the UNIX.I configuration as follows
%module survey%module (directors = 1) Unix //Add this sentence%include "std_string.i"%include "Arrays_java.i"%include " Typemaps.i "%include" ENUMS.SWG "%{#include <src\posioffset.cpp>%}%include <src\PosiOffset.h>
4.Android
Local_path: = $ (call My-dir) include $ (clear_vars) local_module : = posiliblocal_src_files: = Unix_wrap.cxxlocal_cpp _features + = Rttiinclude $ (build_shared_library)
5.Application
App_cflags + =-fexceptionsapp_stl: = gnustl_staticapp_paltform: = android-9
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.
Just saw the typesetting is too ugly, I deleted it, and re-edited an article. Also hope to provide you with learning and communication, self-convenient to consult.
Android NDK Development Swig compiling JNI interface configuration file (ii)