How to bring compute intensive C++ based apps to Android

Video thumbnail (Frame 0) Video thumbnail (Frame 1083) Video thumbnail (Frame 2575) Video thumbnail (Frame 4641) Video thumbnail (Frame 6146) Video thumbnail (Frame 8167) Video thumbnail (Frame 9371) Video thumbnail (Frame 10711) Video thumbnail (Frame 11818) Video thumbnail (Frame 13360) Video thumbnail (Frame 16065) Video thumbnail (Frame 17841) Video thumbnail (Frame 19555) Video thumbnail (Frame 20719) Video thumbnail (Frame 22274) Video thumbnail (Frame 23464) Video thumbnail (Frame 24718) Video thumbnail (Frame 26693) Video thumbnail (Frame 28656) Video thumbnail (Frame 31029) Video thumbnail (Frame 32517) Video thumbnail (Frame 34072) Video thumbnail (Frame 36038) Video thumbnail (Frame 37696) Video thumbnail (Frame 38864) Video thumbnail (Frame 40504) Video thumbnail (Frame 41948) Video thumbnail (Frame 43407) Video thumbnail (Frame 44808) Video thumbnail (Frame 50297) Video thumbnail (Frame 51520) Video thumbnail (Frame 52656) Video thumbnail (Frame 53789) Video thumbnail (Frame 54911) Video thumbnail (Frame 56223) Video thumbnail (Frame 57960) Video thumbnail (Frame 59608) Video thumbnail (Frame 61041) Video thumbnail (Frame 62658) Video thumbnail (Frame 65391) Video thumbnail (Frame 67453) Video thumbnail (Frame 68590) Video thumbnail (Frame 69675) Video thumbnail (Frame 71138) Video thumbnail (Frame 73006) Video thumbnail (Frame 74421) Video thumbnail (Frame 75824) Video thumbnail (Frame 77333) Video thumbnail (Frame 81116) Video thumbnail (Frame 83003)
Video in TIB AV-Portal: How to bring compute intensive C++ based apps to Android

Formal Metadata

How to bring compute intensive C++ based apps to Android
Title of Series
Part Number
Number of Parts
CC Attribution - NonCommercial 2.0 Germany:
You are free to use, adapt and copy, distribute and transmit the work or content in adapted or unchanged form for any legal and non-commercial purpose as long as the work is attributed to the author in the manner specified by the author or licensor.
Release Date

Content Metadata

Subject Area
How to bring compute intensive C++ based apps to Android You already have some C++ code for the desktop and you ever wanted to port this to Android? Then you should not wait to come to this talk. We'll guide you through the typical steps and pitfalls in this porting process using a demo application and our open source geometry app TiGL Viewer. The TiGL Viewer desktop application is used at the German Aerospace Center for aircraft design. It is mainly used to display 3D aircraft geometries, which are computed from a parametric description. The core components of the application are the CAD kernel OpenCASCADE for 3D geometry computation and the OpenGL based rendering engine OpenSceneGraph – both written in C++. Due to its relatively large tested code base and the use of the third party libraries, a reimplementation in Java was not reasonable. ······························ Speaker: Martin Siggel Event: FrOSCon 2014 by the Free and Open Source Software Conference (FrOSCon) e.V.
Keywords Free and Open Source Software Conference FrOSCon14
Group action Freeware Open source Android (robot) Musical ensemble Computer simulation Computer font Cartesian coordinate system Computing platform
Android (robot) Computer program Computer font Standard deviation Mobile app Building Java applet Code Interface (computing) Software developer Weight Android (robot) Java applet Code Machine code Process (computing) Integrated development environment Natural number Software testing Hacker (term) Computing platform Library (computing) Software development kit Physical system
Computer program Mobile app Algorithm Code Java applet Disintegration Mereology Graph coloring Machine code Formal language Energy level Error message Computing platform Computer font Standard deviation Building Android (robot) Java applet Code 3 (number) Physical computing Bit Machine code Cartesian coordinate system Compiler Numeral (linguistics) Emulator Error message Compiler Order (biology) Computing platform Numerical analysis Self-organization Software testing Game theory Hacker (term) Library (computing)
Broadcast programming Computer program Dynamical system Open source Code Computer-aided design Heat transfer Open set Mereology Electronic signature Geometry Different (Kate Ryan album) Kernel (computing) File viewer Aerodynamics Data structure Gamma function Traffic reporting Library (computing) Multiplication Descriptive statistics Simulation Cross-platform Open source Android (robot) Code Line (geometry) Demoscene Electronic signature Word Kernel (computing) Order (biology) Aerodynamics Computing platform Right angle Simulation Data structure Window Geometry Library (computing)
Computer program Theory of relativity Computer-aided design Measurement Data model Geometry Different (Kate Ryan album) Visualization (computer graphics) Order (biology) Artistic rendering Artistic rendering File viewer File viewer Right angle Physical system Computing platform Window Geometry Library (computing) Physical system
Point (geometry) Computer program Android (robot) Graph (mathematics) Kernel (computing) Maxima and minima Mereology Window Geometry
Computer program Geometry Query language Android (robot) File viewer Window Physical system
Point (geometry) Standard error Code View (database) Compiler Projektive Geometrie Chain CAN bus Office suite Maß <Mathematik> Compilation album Physical system Mobile app Information Software developer Interior (topology) Android (robot) Code System call Compiler Software development kit Word Exterior algebra Order (biology) Physical system Library (computing)
Standard deviation Android (robot) Installation art Java applet Patch (Unix) Direction (geometry) Translation (relic) Mereology Writing Telecommunication Object (grammar) Library (computing) Social class User interface Patch (Unix) Wrapper (data mining) Building Interface (computing) Android (robot) Java applet Code Machine code Compiler Software development kit Process (computing) Compiler Telecommunication Interface (computing) Object (grammar) Data type Library (computing)
Web page Standard deviation Android (robot) Installation art Module (mathematics) Open source Writing Telecommunication Computer configuration Object (grammar) Traffic reporting Library (computing) Default (computer science) Default (computer science) Standard deviation Patch (Unix) Building Java applet Android (robot) Open source Code Compiler Software development kit Compiler Interface (computing) Modul <Datentyp> Physical system Library (computing)
Module (mathematics) Scripting language Default (computer science) Open source Computer file Execution unit Android (robot) Bit Open set Directory service Compiler Inclusion map Computer configuration Chain Right angle Computing platform Compilation album Library (computing) Physical system
Android (robot) Line (geometry) Directory service Compiler Projektive Geometrie Pi Order (biology) Set (mathematics) Computing platform Musical ensemble Compilation album Physical system Library (computing)
Module (mathematics) Computer file State of matter Number theory View (database) Source code Android (robot) Parameter (computer programming) Parameter (computer programming) Open set Directory service Mereology Inflection point Modulo (jargon) Projektive Geometrie Kernel (computing) Set (mathematics) Computing platform Right angle Configuration space Endliche Modelltheorie Local ring Local ring Library (computing)
Scripting language Module (mathematics) Open source Computer file Source code Android (robot) Maxima and minima Electronic mailing list Directory service Mereology Modulo (jargon) Inclusion map Projektive Geometrie Sic Right angle Endliche Modelltheorie Local ring Physical system Library (computing) Asynchronous Transfer Mode
Time zone Wechselseitige Information Standard deviation Functional (mathematics) Cross-platform Server (computing) Multiplication sign Simultaneous localization and mapping Strut Android (robot) Time zone Code Sound effect Interprozesskommunikation Latent heat Hypermedia Personal digital assistant Function (mathematics) Reduction of order Right angle Data structure Library (computing) Physical system Library (computing)
Email Android (robot) Functional (mathematics) Wrapper (data mining) Computer file Code Java applet Java native interface Mechanism design Type theory Telecommunication Semiconductor memory Energy level Macro (computer science) Library (computing) Computing platform Physical system Interface (computing) Structural load Software developer Java applet Code Core dump Bit Symbol table Annulus (mathematics) Mechanism design Data management Process (computing) Function (mathematics) Telecommunication Artistic rendering Physical system Window Library (computing)
User interface Functional (mathematics) Java applet Code Interface (computing) Gender Java applet Maxima and minima Bit Mechanism design Process (computing) String (computer science) Interface (computing) Uniform boundedness principle Data type Error message Social class Library (computing)
State of matter Java applet Code Block (periodic table) Structural load Multiplication sign Java applet Set (mathematics) Message passing Process (computing) Internetworking String (computer science) String (computer science) Order (biology) Interface (computing) Physical system Library (computing) Social class
Email Functional (mathematics) Implementation Computer file Code Multiplication sign Computer file Java applet Bit Parameter (computer programming) Virtual machine Electronic signature Process (computing) String (computer science) String (computer science) Interface (computing) Arrow of time Social class
User interface Execution unit Functional (mathematics) Touchscreen Matching (graph theory) User interface Fibonacci number Graph (mathematics) Programmable read-only memory Projektive Geometrie Geometry String (computer science) Boom (sailing) File viewer Right angle Integer Pattern language Resultant
Wechselseitige Information Functional (mathematics) Implementation Computer file Code Maxima and minima RAID Smith chart Projektive Geometrie Duality (mathematics) Uniformer Raum String (computer science) Gamma function Execution unit Email Interface (computing) Number theory Android (robot) Computational geometry Machine code Inclusion map Word Process (computing) Computer cluster Royal Navy
Functional (mathematics) Java applet Multiplication sign Cellular automaton Artificial neural network Maxima and minima Translation (relic) 8 (number) RAID Plot (narrative) Pointer (computer programming) String (computer science) Maize Lipschitz-Stetigkeit Social class Computer icon Execution unit Stapeldatei Directory service Trigonometric functions Mathematics Inclusion map Data mining Process (computing) Normed vector space Order (biology) Convex hull Permian Library (computing)
Electronic data processing Computer file Computer-generated imagery Cellular automaton Maxima and minima Computer-integrated manufacturing Predictability Variance Goodness of fit Cache (computing) Ranking Utility software Uniform boundedness principle Metropolitan area network Social class Chi-squared distribution Computer icon Mobile app Execution unit Email Interface (computing) Java applet Android (robot) Directory service Port scanner Repeating decimal Inflection point Inclusion map Sign (mathematics) Root Arrow of time
Email Functional (mathematics) Computer file Multiplication sign Direction (geometry) Source code Median Set (mathematics) Parameter (computer programming) Distance Plot (narrative) Bit rate Bellman equation String (computer science) Drill commands Software testing Integer Data conversion Library (computing) Social class Execution unit Email Moment (mathematics) Java applet Bit Sequence Disk read-and-write head Sign (mathematics) Inclusion map Mathematics Process (computing) Resource allocation Integrated development environment Oval Case modding Ideal (ethics) Object (grammar) Library (computing)
Execution unit Touchscreen View (database) Java applet Set (mathematics) Voltmeter Parameter (computer programming) Mereology Process (computing) Integrated development environment Semiconductor memory String (computer science) Order (biology) Maize Library (computing) Position operator Library (computing) Vacuum
Programmable read-only memory Wave Degree (graph theory) Drill commands output Curvature Maß <Mathematik> Compilation album Computing platform Computer architecture Chi-squared distribution Execution unit Clique-width Building Flowchart Civil engineering Java applet ACID Cartesian coordinate system Trigonometric functions Compiler Annulus (mathematics) Keilförmige Anordnung Oval Convex hull Lipschitz-Stetigkeit
Default (computer science) Execution unit Functional (mathematics) Number theory MIDI Java applet Android (robot) Planning Computational geometry String (computer science) Normed vector space Order (biology) Motion blur Lipschitz-Stetigkeit Form (programming) Protein folding
Default (computer science) Word Correlation and dependence Data type Simulated annealing
Mobile app Mobile app State of matter Java applet Video game Code Bit Data management Process (computing) Read-only memory Different (Kate Ryan album) Hybrid computer Phase transition Video game Cycle (graph theory) Library (computing) Sinc function
Functional (mathematics) Semiconductor memory Java applet Code State of matter Hybrid computer Phase transition Contrast (vision) Reading (process) Physical system Library (computing)
Default (computer science) Computer program Execution unit Greatest element Number theory Video game Java applet Code Sound effect Mereology Process (computing) Order (biology) Statement (computer science) Library (computing) Reading (process) Library (computing)
Computer program Presentation of a group Video game Java applet Code Power (physics) Befehlsprozessor Semiconductor memory Different (Kate Ryan album) Hybrid computer Order (biology) Video game Normal (geometry) Cycle (graph theory) Error message Maß <Mathematik> Physical system Default (computer science)
Identifiability Computer file INTEGRAL Disintegration Writing Googol Compiler Physical system Task (computing) Run time (program lifecycle phase) Gradient Android (robot) Code Planning Directory service Line (geometry) Word Process (computing) Personal digital assistant Order (biology) Interpreter (computing) Compilation album Right angle Lipschitz-Stetigkeit Automation Task (computing) Window
Standard deviation Android (robot) Intel Mobile app Installation art Device driver Mereology Arm Emulation Medical imaging Virtual reality Semiconductor memory Graphics processing unit Standard deviation Arm Theory of relativity Android (robot) Computational geometry Price index Device driver 10 (number) Software development kit Emulator Personal digital assistant Computing platform Software testing
Emulator Multiplication sign Computer simulation Bit Cartesian coordinate system Compilation album
Emulator Direction (geometry) Forest Bit Event horizon
Medical imaging Virtual reality Emulator Regulator gene Touch typing Artistic rendering Android (robot) Cuboid
Mobile app Slide rule Information Computer file Block (periodic table) Debugger Debugger Android (robot) Directory service Cartesian coordinate system Projektive Geometrie Computer configuration Computer configuration Sinc function
Mobile app Email Execution unit Polygon mesh Patch (Unix) Clique-width Block (periodic table) Debugger Patch (Unix) Lemma (mathematics) Android (robot) Directory service Menu (computing) Directory service Word Emulator Computer configuration Computer configuration Different (Kate Ryan album) Pattern language Gamma function Computing platform Library (computing)
System call INTEGRAL Block (periodic table) Multiplication sign Cellular automaton Cartesian coordinate system Statistics Emulation Time domain Annulus (mathematics) Natural number Gamma function output
Point (geometry) Dialect Execution unit Number theory Real number Variance Menu (computing) Computational geometry Plastikkarte System call Duality (mathematics) Oval Order (biology) Moving average Cuboid Quantum Alpha (investment) Sinc function
Web page Mobile app Standard deviation State of matter INTEGRAL Debugger Software developer Data storage device Directory service Computer configuration Emulator Bit rate Personal digital assistant File viewer Right angle Computer architecture Geometry Library (computing)
Projektive Geometrie Mereology
welcome to my talk about I'm glad that at least some people fall on the way into my talk on my name is not easy to and from the German Aerospace Centre here in Cologne from the group or for Institute and simulations of the technology and today I'm going to talk about how to bring the compute-intensive C + + based applications to them for a platform and just a brief outline here about my talk 1st I'm gonna try to motivate why this
might be important why you have to program native code for and weightings for Android standards programming languages jobless in might know and as introduction I will want to motivate that and with the T 2 0 which we are developing at the German Aerospace Center which we're reporting to them by platform and so this is why we do that actually here then I'd like to talk about the hiking aspects so what steps you going to go through when you want to bring your code to Androids so and and how to prepare India the environment for a native app development and I'm gonna talk about how you compile all your party and dependencies like libraries and everything you're going to you're going to use and I'm going talk about how how to use the Java Native Interface to communicate between the job of code
in the C + + codes between both will and for 3rd I'm going to talk about them the building itself so how to integrate the so called native development kit from Google into the new gradability systems and finally I'm going to talk about and running everything and testing everything on the later how to do it efficiently so not using surrounding the nature and how you
can also use that in order to debug your code from clips and within KGB program so 1st of all why do you want to do that so it's probably not the standard way of programming and red apps but you might have some already large place and desktop application for example and you want to bring back Europe program to the right platform and you have already is so much code base which might be tested already and rewriting everything to Java might not reasonable to to numerous reasons for example you might introduce errors into coordinate and you don't want to do that of course have also you quote might depend on how the 3rd party libraries and which you don't want to read about in general there might be no color department 1 so it's basically
just too time-consuming and too expensive to do that also have another respect our debt and numerical algorithms are already implemented or most implemented in C or Fortran because the C and Fortran compiler B highly optimized producing very fast code and so this is the reason why you would use that from C or Fortran and also if you want to write a game for example you have to have really performed graphics folk performance physics computation you might also want to that from C C + + whatever so from a low level language which gets all everything from from him on the phone of course on the other hand to native code is harder to right and also to the back of course and it has to be ported to an organ which makes it a bit part of course so let let me say
some words about the TV program we're doing at the German Aerospace Center it's a standard central them geometry library and your program used by many simulation tools for aircraft design actually and 4 was ization and what you can do is depicted here on the right side so incendiary have achieved a program on the T. do library we have some parametric description of all aircraft which just described the overall geometry actually and then the library itself creates a geometry and transfers the geometry of the aircraft to different tools for example to compute aerodynamics to compute infrared structure of the aircraft to evaluate the structural behavior of the aircraft nevertheless plastics and the coupling between the dynamics and structure or you can also use that in order to compute the major signature both signature and infrared signature you might want to use that moral for military aircraft since this is important in there and to use written in C + + and it's actually medium-size codebase symbolic 50 thousand lines of code but the important new we're using we're not doing all the mapped by ourselves we
using a open source and geometry kernel it's called cascade it's about 4 million lines of code and you don't want to rewrite that in java right and so this is why where we want to do that here a report that and for Android part we're using the 3 engine Open Scene rather unknown anyone heard about that so Everything is actually multi platform it runs on Windows Linux and Mac and also after porting on and virtue and so and he just have a look at
what the teacher can do so here you have the viewer of the the geometry library and can use that to create measures of the geometry for the dynamic
relations in the you can use exchange 5 formants to bring that into CAD systems in order to model afterwards more export to blend into some rendering and dieselization or when we did that last year year you can also order to make the difference of also quite nice and this is how the viewer looks like under different platforms and the nodes
that windows and on and right and I'd like to show you 1st of the program on Windows and I'm going to talk about it all the processing and financial you the same
program on Android so let's started Europe it's here Windows program and of using windows of the example let's we
handling aircraft it it was building up can close it
again and we it you can see
how it is used as a CAD kernel or to create a geometry so you see step by step all the parts are generated you can select the different parts of the graph you can compute the points on the wing of like is another aircraft we just recently developed was this year just a joke of course
so yeah that's the MTV program so now I'm going to talk about how we actually do
this are you going to port and I
think this was just as small motivation here so why did we do that for N actually we didn't have like
any scientific reasoning query most Indian German aerospace and are we using Linux systems of Windows systems the only reason we have because we can do it and it's funny
so let's talk about the heading aspect and what you
need in order to start out with the Native development is indeed and what is detailed
cost money made that might be like a good point where you can just look into the world into the ground here just ask who of you did already and or at the development of the new OK so some of them and who is developing desktop at word just C + + code for desktop anyone using C + + OK also some and who
all of you have to use C + + from with an Android OK to so this is not an expert talk I so you probably don't get any experiences but just more of the introduction of that OK so my so the minority view as suspected so to 2 people here the dead already in so you might know all the steps you have to go through so the next step you have to Don alternative development quit from Google and this includes the cross compilers that you can compile your C + + code to the 2 4 4 7 4 hours office 86 are also from so all this to change confined in there and it has sound and cable system which is the standard error of the system in order to compile the code of 4 native or in order to compile native course it's from Google it's based on makefiles and you also have a dual called and a KGB to deduct the native x code and Joseph some and what specific libraries and their in order to for example to talk to the locking mechanism of and all in order to query the information of involves or whatever so there are some extra libraries and then and what you also might want to download users see call to tools in order to cross compiler or dependencies uracil you probably have dependencies to other libraries from the project so we have to cross them I'm also gonna talk about that how you can do that so 1st of course you have to install the can and indicate the didn't already do that did that that and then
now that was the I think the most complicated part actually cross cross-compiler all the dependencies to Android and also you might have to patch all and or some of the worst dependencies if you are not completely platform-independent and then you have to write a Java interface class and which you using for the communication between the job under C C + + world so you need to let this extra class for that then you have to write the bucolic that combines both worlds C and Java and so which calls
the native code and translates job objects and job on data types to see and also in the other direction of course and then you're creating shared library containing your native code then you're designing a user interface which talks to your JNI wrapper recently developed and so but you can talk to your C + + and finally you have to build that compiler everything the native code and the Senate steps to build the rest the job at hand I'm going to talk about the
steps here of course so which is often indicates specific and so
1st of all you think that party library for how to create cross compiler and is not really nice assumes
that it's quite involving and you don't get much out of that but you have to do that of course but 1st of all let me mention many open source libraries are already ported for Android so please refers to look for them and and use these available you can like as as this lots of lots of report that so and you can find many of them already on the Android give up page for example like the standard by which the banks and whatever they already there but if you still have to reported library so if it doesn't exist for an hour so you have 2 options then you can either compiled the library using the default
it's system of the library that could be altered tools for scenic whatever libraries using and if you did that you're creating also when you have to package everything into a so-called previous module I'm going to talk about that other than that the other option is of course you can still write the data and the default system of the library right you and right and K 5 and beat everything on your that's the other option and this is what you need the open source libraries are actually doing but that might be a bit too involving if you have a large library like open casket and you don't want to do that so as an example I want to talk about for example how you can cross-compile using its he make based library this unit
based tool so 1st of all you have to install a so-called stand-alone compiler toolchain and ended and would indicate comes up with the script that's called makes them the toolchain and you call that just defined which platform and looked at from your targeting and where you want to install that and you get a stand-alone tool chain the stand-alone which includes all the compilers all libraries to include fights everything you need it just installed it into 1 directory then you're creating a toolchain file which I call you and want to shame books make and
here i'm just defining where I installed my to James Watson bands directory of that and this is you really important these both lines here we're setting up the C and C + + compiler so after that see knows that you're not compiling the span of the system C
compiler but with and what 1 and these or important in order that prevents us that prevents that the makers mixing system libraries or system compilers with and what 1 so just use that and you should be saved and then found when you configure sumac project just call seeing that with this additional
arguments you make Putin file and at the end right just recently written 5 and in that way should be able to translate assume a base so half-heartedly of course you might still need some pitching of the course so if you have
that you're not bound so we have to package everything in pre-build and right model and
this is an example here what you can do is we have to write a number and adult and K file where you actually just define your library view of what you just created and into so here I was just module on library PT kernel that's part of the Open cascade just as an example and in the next part local source file looks like a source file but it isn't it's already a compiled 1 local library here then I'm setting up include directories since I want to use this library I have to say say after state where my projects finding all includes of this library an important part this here I have to include a pre-built static library
script which just makes In the back on the rest so just add this thing to worry install path of the recently created library copy that they're and you're done so if you have created now a pretty good and right model by cross compiling the other way of course is to override the defaulted scripts and justified in all and you can have
to write a custom and and find and this is a really simplistic 1 for a
full library we are doing Caltech C and it's similar to make again yeah and defining what my library should be like takes studied here way all modes include path our and here I am using wildcards just adding all C C files from the source directory and this source files are compiled to library and here in that part I also have to define of course my dependencies of this library and depends on the accessibility example occurred so that in the end my project knows what other libraries have to be here and of course for large project for large library this
can be really really large this make so that might not be working as just on the cross compliance you have to decide what what where have to go just an example and how we
ported to the demands that
all because Kate oneself if only lent support to Android it was not completely told media platform independent
you might know about on the notes you have to reduce C library right that's the standard C library and it has provides some them standards structures stand and prepare methods and and what is not using the new standard library instead they have written there on standard libraries called bionic C and it's a bit different from do you see in every for example it has no times on function and all these effects was using it so we have to find a way around that we just sitting here like fixed time zone but that might not be working in your case and also so that the juicy has passed with structure within a member G course which includes username I don't find that on the fantasy that way
so again you have to find a way around it and it is about consumers also spent a system B process communication calls again you have to find your way around that for example these all these function for a symbol for management and shared memory access you don't have that quite important is still at them when you're changing your code for and you can use the if death Android mackerel since the today and indicate which finds underscore underscore Android was going to score macros so you can always asking the code and on compiling that find white or from the hopefully as or whatever so use that so that to maintain the same code base of 4 all your platforms you don't want to write a different code for right then for for other purposes also in open cascade itself and she was using a lot of Dixie level command center for the rendering for example and we had to do it it everything with respect to the rendering and we have to compute completely and change rendering engine and that's why we're using overseeing rough for that so as you can see and this might be involving there are other libraries which are quite simple to report but this 1 was a bit more involving so that was the
short third-party libraries stuff I mean you have to use that where you have to do that probably but that's not particularly defines what is batteries and then when you're really starting to the development of and I'm going to talk about now how to talk now to between ball was to Java code in C C + + code and what enables you to do is this the so-called Java Native Interface JNI so that enables communication between both worlds and it's actually done realized and by you compile everything into a shared library on Windows that's a DLL on Android foreign it's but it's all files and java just loads this library and calls functions from that library so the JI provides mechanisms to Lotus libraries using the system the Library command
that it provides functions to convert the Java and C data types and it has a mechanism also for the other side that you can call a Java methods from C sometimes you also have to do that you have to in Florida you user interface that something happened in a complicated for example about that and what was not surmises that we have to write new code which is in between here would say using gender dominated interface by hand or by itself and that might be a bit tricky and error prone and that's why there is a tool job which is called I which I translates a Java class in 2 half way for a c and you I really emphasize to do that and I'm going to show you later on how to do so 1st decide which 8 interface from job on which reflects
some hold the library which on the other side like on C and that's that's called Native Interface and just for now debate what this means so you have I just defined free methods which
should be initialization method for my C library and then just a method which retrieves a string I call that that name and you're method we distinguished sets strings important message here is that all of these methods since you don't have a implementation for that you have to call or state and estimated that
Java OK the code for that executions should be inside a shared libraries that's been in this world In order to can call these things you have to load the shared library which you would creating and this is the the block what is doing here so when when using this class in 1st the 1st time it loads of library and here I just quote sorry native so that's really important if you don't do that Europe will probably crashed so in the next that using the job wage command 1 to that
class and this would generate ahead from publishers later on dispersed and they had a file looks a lot like that an automatic created the function names are quite nasty with
long so we have a job pretty face then you have here the package the have class name and finally a method name and it's quite error-prone because of his long strings and also a the signature of your functions so what particular argument to have and which which where you calling that so it's it's a bit trickier that's why should really use the tool generates to generate that and then if you have that then you can start implementing all these things here and just an example I don't go into time I will detail what I did here but here I created pair a extra C + + code files and did implementation and all and show you how to do this can
detail so I just
prepared the an linkage project but and that that's
user interface for for my tutorial I'm gonna show
you it has 3 buttons and each button should trigger a C function right and just for demonstration purposes the first 1 should calculated at a few matching number he we just and the integer so we want to calculate the Fibonacci number and we should get a result and these both patterns are for setting and getting a screen here which is interesting which is suppressed at the string and then press kept the string and then it should be displayed there so
quite simplistic not particularly beautiful bathed which should to demonstrate what I'm going to do know so let's have a look here into the project who what you
can see is there is a JNI folder that includes your native code that includes a C
code and that's ever look at I already implemented or summer the implementation for this 3 functions here's the interface header file just to mention number didn't set name s in the as in the job word and here's the actual implementation quite easy here we have a global variable storing some string I just Saudi full name there uh next I have to Fibonacci computation in a recursive fashion not particularly fast but still just for demonstration purposes here a function
that returns the string reassortant variable here function that changes this string became so now we want to know he actually do the translation and so this
time we have to call on our tool job H I already mentioned in order to create a pupil and let's do
that so all I
prepared the batch so now we're in here in the directory and you can see OK here's mine library and and 184 and so on and no that's invoked the Java tool that tell age I have to define the class lower so that the pathway can find all the compiled classes it's don't have already
in been directory 1 here just prints me Kane-Miller should be have been directory
so been classes and then I have to enter the name of my I also my
own interface class the 1st Canadian so we
have to add to the package man debility good squad tutorial thought and now class name throws coordinated so need to so that work and now we should have a new file it's you generated the utility of our and so on in the header file so let's have a look in the header file you it's an insight that
generated them to see if this refreshes there we are so this is the automatically created and file from from our class no we are or have to implement everything her so the next step we have to create data according to the see 5 all sequence of files and you source file thus he pp now we have to include this header file and of course we also have to include the header file for everyone to read so knowledge use some of its magic we're just implementing everything automatically moral so now we have that here or
function bodies so just let me put my library had fire on the side no 1 of working not thank so OK so 1st let's implement few not come population that's quite easy this function accepts an integer and just returns an integer and as you can see this as a function body has already in the job j into argument so you can just use that don't have to convert it particularly dangerous assignments integer so we're just calling our library so if you do not passing the argument then that and redundant so that it was quite easy actually the next function is a bit more involving since we get names return to C + posturing and we have to convert the sequence prostrating to adopt a string and return that and fortunately the JNI has functions for that and we'll using the so-called JNI and rate environment the object for this so 1st we're just retrieving the string hence the string name equals minus from our library so that these are not we have to convert it it's so as already mentioned there is JI environment objects and reason that it has lots of and methods for converting data pipes and we have been particularly using the new strain UTF function and we're just passing it pointed to correct like that and we're done FIL that wars not so local hot but then you have to remember all the names and get to know how to do that so finally this set name function is the other direction so we get a job string here when we look into their this function body has a jobless string arguments Mr. converted into c string and pass it to our library so let's do that 1st test find some names here and environment and but 1st of all we have to convert the job of string to see history so to a character in the string equals the again using the environment and objects and using this time the function tell was and what was called again we we get string UTF characters this is the function to convert job strings to see strings and you the Dallas string objects and you can edit distance moment wonderful that so now we have a node that function created us a character here so that involved also some occasional memory and in the end
we have to free it again in order to prevent memory to keep it in mind so now we can ask that to a library set
names string it was easy
part have as I already said we won't will have a memory so let's do that again we're using the environment for that and it has a really use the screen UTF characters the 1st argument with positive job a string and the 2nd the string and we should be so that was Morris R. cardinal we you've written the view layer between the job and the
sea and let's have a look if we can compile everything so so you can see it here the
compilation work and you can also see that it did
compiler of thing for 2 architectures here the compilation of my lips and the defrost once CPP was compiled for of
architecture and and another around full it's 86 and it's important to know all you have to add in Europe application and although architectures you want to support if you want to support also
makes you have to add that there else that won't run on platform which would just crashed on OK so that worked just now that I have been related via we can try out right so just press
plane and it should start
later there we are so that they have that's tries to match computation just enter a number here concluded that looks good you can just try it smaller values in order to check this is right and looks correct so the Fibonacci computational works of course and just try out the other things if we are using again name function it should retrieve the global variable from the string just have a look at what it looked like he and my
lips CPP was defining the string at the beginning with default name just 7 look if that works
OK we're getting the default name isn't an answer that looks good and now we can see that right something as in there I trust I have all had crossed plant so the name no pressing get name again OK there where that's really nice so this is actually
was where is everything you have to know if you have a really basic API between all words so if you just stick to simple of barely data types so let's continue the
not like to talk about the life
cycle of native quote since it's a bit different than the job so all of you who already room and you might know about the life cycle it's a bit complex you have several states of that that can be in several states you have running state you have a state which is Paul's to have those baseball stopped and starting and so on and for all these changes between
states there are methods in the activity API where you can react on the state changes and what there was no Madonna's that for example in on policy the state would be stored so when you lay don't go into the app again the State of New and Restored so that everything looks the same
when when you were leaving there but you have to do it manually it's it can be quite and to do that I In contrast them when you were renewed exiting for example as a and such a hybrid that the library which we're creating that remains in memory that means no status changing so the library remains at the same state that means of course if you're exiting the it recites memory and that might be a memory for your system of its if you have a huge and so you might want to clean your library for reading so we have to manage everything by your own you have to write all the state changes functions and call them from your Java code and the don't do that you can also use that as a feature of course since you closing your that go into and you have the same status before and each I also want to show you what I really mean with that just go back to the and later here so
not just have a look at what what what standing there so you have high all 1st
constraining their you have fight has number ended and you again high or low and 1st at the bottom and when we're reading all of our at and go back into the all the job part should reinitialized
onwards not here the of that statement straighten effect OK it's going back into the program so that as long as I but that's in main initializations everything is back at at the we said it actually but if we are pressing get not the default name should be there instead high also for someone already that before so the library knows everything and it maintains that last day and in order to reset we have to kill actually there and start again let's try this so
killing the and if you start a program and it looks at 1st and the same but knowledge from present in the 4th thing so this is actually the difference and you have to keep these things in mind in order to minimize that now the it's suspended yeah it's a suspended that's yeah it's standard like on other operating systems and but of course if it's it keeps the memory all the memory which it needs a if you use this from from the all all around so yeah so error whichever involving at doing lots of
invitation and you go back up to go back into the main thing it will consume any CPU power OK so but it's it's really different from from the normal life cycle so that was at about life cycle not I'm going talk about the packaging it's have you want to watch 41 and so this is how to actually integrate
then decay into the degraded system I'm done or if you have heard about greater it's a new both system for friend right and places Apache and or maven and it's now used by the new and words to use so there's a good reason that you actually should use greater but you have to integrate all indicated steps into have actually guru recently added to indicate integration integrated but it's quite a body at least when I tried that for a simple this creates and the end and K. makefiles automatically
but they don't work so all you have to provide work-arounds for that and so 1st you have to disable the automatic creation invites your own and would makefiles Fourier for a native I call and then you have to define a custom-built tasks integrated which itself calls indicated that command and this is what it looks like so 1st you have to register the lips directory which which was created on so that it's the patched packed into the k and disable the automatic creation of and identify file both plans arguing that the 1st this great registering lives and the 2nd best enabling the automatic creation them this is how you can define a customer the terrorists so I just called that indicate built and here doing just asking if my system I'm fighting years windows all minutes and then not winds windows I'm using the command indicated talked command and in the other case just the plane in the cable and here in the last line this defines the command line of this tool so what I'm doing here is i'm minus j optional order to activate parallel parallel compilation which makes the interpretation is much faster than it just ask for their made processes here so this quite nice and finally you have to add this new creative tasks to you the dependency just we just added to the compiled task so that's basically it so that you can use gradient and everything works or should grow
actually so let's come to run and testing that so when you're not using the when you're writing computing tens of hydrogens or apps you will notice and found that normal and right images to slow since it emulates ARM instructions all of the instructions has to be translated to x 86 and that it tends to be really really slow and you probably don't want to have that
so what it can do instead is that your speech into at x 86 based and later mystique you exploration who will provide some this kind of memory with their STK but it's not the standard in later so we have to download x 86 based on Android and image and installed them lemonade and so on but it can also do is you install the include H A X and exploration driver which are and still provides further boost of off the relation and is also part of the and what's the case I want to commend to that and then all again the hard part is you have to recompile everything to 686 again not only to arm but also takes 86 with another indicator which aims and you
have to add x 86 are targeted to the ABI inside the application and K. follow already compilation so we have to prepare thing but then you can use that and when you use that this is what you get and
finally and this is not the time I can show you that on and right now have from
within the canadian maybe the sole here is an X. 6 based simulator it's still so that
a bit slow sometimes marked the X are working really so here is the CEO of that view on and his which
the direction here and that's called some aircraft in the
opening the same what we had before so this is knowledge looks like and you have like an as before the rendering it's kind of and so it works quite well if thing actually what you also have fallen on the desktop and that that's quite as in the here they are of course is a bit more
simplistic then the act on the desktop but it works as expected it also in the forest does tell all the touching event handling I have it uracil on that your farm and you don't
metamorphosis you anything but touch selects to pension everything it works yeah as expected so I really emphasize for using medics 86 else all the rendering will depend please blissfully actually couldn't use that so a then you might have seen that I'm not using the standard ended and later images quoted emotions
it's really fast it's also fast minister and regulator and that is using this all 86 based using Buchan box on the dividend only probably know much of and then you can download many preconfigure devices for example I for myself free devices and related with Nexus 7 and 10 and that she wants to can just switch between them and so it's really comfortable comfortable
and I really recommend using this 1 so finally as my actually last slide I'm going to talk about how to the block everything in eclipse and with that in the KGB since that's can be quite tricky
1st you have to define the
inside the application and kind of have to be defined as a debugger that you have all the developed informations and that of course and then in the next step you have also will have to add in k underscore about options to the debate indicate good command is really important since this that's some extra files that TAP-k with all these fires dividing 1 and then there is the back eclipse which actually prevents the bonding over or which so that the body doesn't work soul you have to run once the for for the project also they indicate you be common from command line so let's try this 1 as of entitled in the gym and generation and related to the
bearing only works with the patch so you have to install pattern to them later else it won't work so let's have a look so
if we have a look here into directory there are 4 not for each platform and the shared library we we're creating and now we have to change the built we have to add to the command and that indicate the block equals 1 option so applied there we are rebuilding everything you can always see our that there were created to different pilots GDP sovereignty to be set up which are necessary in or else you want to be able to to do that but as I already mentioned you have to call once the G and a KGB command else dividing 1 word so 1st we have to start
that here on the on the nature of the respective installed actually
just 1 now there we are
and why it's running we have
to call the and the KGB commands GDP the timing investments no way that connects now to that OK that was actually already in the and now we can use that from the kids so
just all we can do about it as a
C + + and what is really important here is that knew the block integration you that there is a 2nd coordinated application helps you will be able to about that so ask us notice which is expected
here in the background they have already started and not just tried to set some breakpoint that's said here if you Bonacci computation
for example and yeah you know we can try it so we saw interest on number and now in the background the the
breakpoint point was reached and we can also see the value we can also change here um 25 the variance 3 just run this everything so and now we get we so real call course since
I change the so this way you can do about it and you have to really stick to the instructions I gave else that's really hard was really hard to find out for myself all these steps I really struggled like 2 days or whatever in order to fix all these things and find out the box and work-arounds for that so that is really helpful here
it's all just come what do you
expect with the debugging like ball today's mentioned that since that was all lacks a month ago yeah yeah yeah and you ask about and studio and if it's working that I didn't try
that out so it probably will work there and probably will also work better but on the other hand and indicate integration and rights to use quite immature so if you do indicate developing the development I would stick to eclipse for yeah this you of you all what yes so where the good question so I'm repeating a few resist asking how if you're just all the native libraries for diffing architectures and 1 and if that might increase the MAPK size and that's true actually 1 library here is about 12 megabytes for since we using a lot of the state and so if Europe we supporter of 3 different architectures so you would end up with 36 megabytes and have and that's probably too large for users to download work depends on but what you can do is you can compile or you can create 3 different in the case and upload them into their at store and and you will only get the right in the case so there there's the instruction of Google and wet rate can just read that and so we did that so we each educators about 12 megabytes and you just get the right it became for a atomic so that's my thing and so here it's in this store or you can download it it's not only for aircraft geometries but you can also have a look and standard CAD exchange 5 formants like step 4 pages or whatever so just few free to try it out it comes with some example files already so you can try that so if you have any questions please ask at
the project and the demonstration project also did have just try it and she wondered if you 453 also to experiment with that can write me some questions about it yeah it was used in a lot people
and the the people and I have never experienced problems but that's sorry I condense into it other questions OK so that part questions more than you thank you for attending my talk just have fun here and we are with the German and we have both here and just when you go out there would be nice if you come by if any questions or we also have a kicker and match them to want to play kicker just come by and yeah you things