Android NDK Development Swig compiling JNI interface configuration file (ii)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.