SlideShare a Scribd company logo
DLL Building Blocks 
Yes, we scan… 
http://en.wikipedia.org/wiki/Web_of_Things 
Max Kleiner 
Script: 362_maxon3D_EKON18.TXT
Agenda and Tutorial 
(DLL 32/64 bit) 
2 
http://www.softwareschule.ch/download/maxbox_starter28.pdf 
• Call a DLL 
• Call a DLL+ (Interface, Callback, Events) 
• Build a DLL 
• Recompile a DLL 
• Android NDK and Lazarus 
http://scholz2000.com/ 
136_sysinformation_dll_EKON1.txt 
A Short History of Time 
1991 Application Program 
1995 Application 
1998 Applet 
2010 App 
2015 A (Scholz2000, Android, Arduino, ARM)
DLL Primer •• 
Call: If you want your library to be called from programs compiled with 
other compilers, it is important to specify the correct calling convention. 
•• 
Create: A library can be created just as a program, only it uses the 
library keyword, and it has an exports section. 
•• 
Let's get back to the topic and create a DLL callback function: 
•• 
1. declare a function type 
• 2. the function itself 
• 3. define the DLL reference 
• 4. then implement the function in the client 
• 5. and call the DLL: 
3 
136_sysinformation_dll_EKON1.txt 039_pas_dllcall_EKON2.txt 
070_pas_functionplotter_digital2.txt
CCaallllbbaacckk hhaacckk ssttaacckk 
• 
4 
Callback example in client unit 136_Callback_dll_EKON6.txt 
----------------------------------------------- 
interface... 
1. TCallBackFunction = function(sig: integer):boolean; 
2. function callME(sig: integer):boolean; 
implement... 
3. procedure TestCallBack(myCBFunction: TCallBackFunction); register; 
external('watchcom.dll'); 
4. function callMe(sig: integer): boolean; 
begin 
{whatever you need to do, case of...} 
showmessage('I was called with'+ inttostr(sig)); 
end; 
5. procedure TForm1.Button1Click(sender: TObject); 
begin 
testCallBack(callMe); //subscribe function in DLL 
end;
Create a DLL 
5 
Callback in the DLL 
In the DLL you would also declare a function type and a 
procedure (or function) itself, so use it like this: 
type 
TCallBackFunction = function(sig: integer):boolean; 
procedure TestCallBack(clientFunc: TCallBackFunction); stdcall; 
var sigAlive: boolean; 
begin 
{timer stuff... 
set the signal...} 
if(clientFunc(55)) then sigalive := true; 
end; 
exports TestCallBack;
http://max.kleiner.com/dllplus.htm 
6 
Export an object-reference from a DLL is one approach to get real OO-access 
to a DLL. The DLL must create and return the object, so the client 
gets the methods without encapsulating. 
unit income1; 
interface 
type 
IIncome = class 
public 
function GetIncome(const aNetto: Currency): Currency; 
virtual; abstract; 
procedure SetRate(const aPercent, aYear: integer); 
virtual; abstract; 
function queryDLLInterface(var queryList: TStringList): 
TStringList; virtual; abstract; 
end; 
036_pas_includetest_EKON3.txt 
036_pas_dynlib_EKON4.txt 
036_pas_DLLTesting_EKON5.tx
Solution FPC ELF32 
shared object 
7 
32-bit EXE loads 32-bit DLL, 64-bit EXE loads 64-bit DLL. 
************* Simple Sequence Diagram************** 
Client DLL 
¦ TestCallBack(clientFunc) ¦ 
¦---------------------------------------------->¦ 
¦ clientFunc.callMe(sig ) ¦ 
¦<----------------------------------------------¦ 
¦ ¦ 
¦ true (or something to return) ¦ 
¦---------------------------------------------->¦ 
¦ ¦ 
http://wiki.freepascal.org/Android_Programming 
http://www.softwareschule.ch/examples/440_DLL_Tutor2.txt 
Tutor: http://www.softwareschule.ch/download/maxbox_starter18_3.pdf
Solution NDK 
The NDK is a toolset that allows you to implement parts of your app using 
native-code languages such as C, Pascal, Object Pascal and C++. For certain 
types of apps, this can be helpful so you can reuse existing code libraries 
written in these languages, but most apps do not need the Android NDK. 
Typical good candidates for the NDK are CPU-intensive workloads such as 
game engines, signal processing, physics simulation, and so on. When 
examining whether or not you should develop in native code, think about your 
requirements and see if the Android framework APIs provide the functionality 
that you need. 
You have to use the Android NDK to recompile the library. The ARM 
architecture is completely different from the x86 architecture. The system calls 
are different on Linux and Windows. 
8 
http://www.ntu.edu.sg/home/ehchua/programming/android/android_ndk.html
NDK Need Things 
If you have the src files for the DLL, try recompiling as an ELF32 shared object, then link 
that instead into your Android code (- 
below is a Windows solution): 
set NDK_HOME=C:Androidandroid-ndk-r9c // customize this var for your own location 
set LD_LIBRARY_PATH=%NDK_HOME%platformsandroid-18arch-armusrlib cd 
REM -- TEMPORARILY COPY SOME LIBS COMPILER MAY NEED 
copy %NDK_HOME%platformsandroid-18arch-armusrlibcrtbegin*.o . 
copy %NDK_HOME%platformsandroid-18arch-armusrlibcrtend*.o . 
REM -- GENERATE YOUR OBJ FILE 
%NDK_HOME%toolchainsarm-linux-androideabi-4.8prebuiltwindows-x86_64binarm-linux-androideabi- 
gcc.exe -g -I%NDK_HOME%platforms 
android-18arch-armusrinclude -c -fPIC YourLib.c -o YourLib.o 
REM -- GENERATE SHARED OBJ FROM OBJ FILE 
%NDK_HOME%toolchainsarm-linux-androideabi-4.8prebuiltwindows-x86_64binarm-linux-androideabi- 
gcc.exe -g -L%NDK_HOME%platforms 
android-18arch-armusrlib -shared -o YourLib_so.so YourLib_so.o 
REM -- finally, remove the libraries previously copied to src directory 
del .crtbegin*.o 
del .crtend*.o 
9
Optional: Create <project>/jni/Application.mk. 
Build your native code by running the 'ndk-build' script from your project's directory. 
It is located in the top-level NDK directory: 
cd <project> 
<ndk>/ndk-build 
I discovered that to use the build-ndk script, I don't need a real project. 
I created a folder project, with nothing in it except another folder jni, and put all 
my sources in that folder. 
I then created the Android.mk file and ran the script as described in the ndk docs. 
10 
Here's the general outline of how you work with the NDK tools: 
Place your native sources under <project>/jni/... 
Create <project>/jni/Android.mk to describe your native sources to the NDK 
build system 
http://developer.android.com/sdk/ndk/index.html
Thanks! Links to Blocks 
the source is the code 
http://www.softwareschule.ch/maxbox.htm 
http://sourceforge.net/projects/maxbox 
http://en.wikipedia.org/wiki/Arduino 
http://www.softwareschule.ch/download/webofthings2013.pdf 
Book Patterns konkret 
http://www.amazon.de/Patterns-konkret-Max-Kleiner/dp/3935042469 
maXbox 
https://github.com/maxkleiner/maXbox3/releases 
11 
http://max.kleiner.com/dllplus.htm 
http://www.softwareschule.ch/download/dlldesign_ekon9.pdf 
http://developer.android.com/sdk/ndk/index.html 
http://www.ntu.edu.sg/home/ehchua/programming/android/android_ndk.html
Questions? Code a World 
hack the earth 
12 
Yes, we hack… 
https://github.com/maxkleiner/maXbox3/releases

More Related Content

What's hot

C++ Code as Seen by a Hypercritical Reviewer
C++ Code as Seen by a Hypercritical ReviewerC++ Code as Seen by a Hypercritical Reviewer
C++ Code as Seen by a Hypercritical Reviewer
Andrey Karpov
 
clWrap: Nonsense free control of your GPU
clWrap: Nonsense free control of your GPUclWrap: Nonsense free control of your GPU
clWrap: Nonsense free control of your GPU
John Colvin
 
Skiron - Experiments in CPU Design in D
Skiron - Experiments in CPU Design in DSkiron - Experiments in CPU Design in D
Skiron - Experiments in CPU Design in D
Mithun Hunsur
 
Summary of C++17 features
Summary of C++17 featuresSummary of C++17 features
Summary of C++17 features
Bartlomiej Filipek
 
HKG15-207: Advanced Toolchain Usage Part 3
HKG15-207: Advanced Toolchain Usage Part 3HKG15-207: Advanced Toolchain Usage Part 3
HKG15-207: Advanced Toolchain Usage Part 3
Linaro
 
С++ without new and delete
С++ without new and deleteС++ without new and delete
С++ without new and delete
Platonov Sergey
 
Tiramisu をちょっと、味見してみました。
Tiramisu をちょっと、味見してみました。Tiramisu をちょっと、味見してみました。
Tiramisu をちょっと、味見してみました。
Mr. Vengineer
 
Tensor comprehensions
Tensor comprehensionsTensor comprehensions
Tensor comprehensions
Mr. Vengineer
 
Дмитрий Нестерук, Паттерны проектирования в XXI веке
Дмитрий Нестерук, Паттерны проектирования в XXI векеДмитрий Нестерук, Паттерны проектирования в XXI веке
Дмитрий Нестерук, Паттерны проектирования в XXI веке
Sergey Platonov
 
Exploring the Cryptol Toolset
Exploring the Cryptol ToolsetExploring the Cryptol Toolset
Exploring the Cryptol Toolset
Ulisses Costa
 
Intel IPP Samples for Windows - error correction
Intel IPP Samples for Windows - error correctionIntel IPP Samples for Windows - error correction
Intel IPP Samples for Windows - error correction
Andrey Karpov
 
Intel IPP Samples for Windows - error correction
Intel IPP Samples for Windows - error correctionIntel IPP Samples for Windows - error correction
Intel IPP Samples for Windows - error correction
PVS-Studio
 
GPU Programming on CPU - Using C++AMP
GPU Programming on CPU - Using C++AMPGPU Programming on CPU - Using C++AMP
GPU Programming on CPU - Using C++AMP
Miller Lee
 
Gor Nishanov, C++ Coroutines – a negative overhead abstraction
Gor Nishanov,  C++ Coroutines – a negative overhead abstractionGor Nishanov,  C++ Coroutines – a negative overhead abstraction
Gor Nishanov, C++ Coroutines – a negative overhead abstraction
Sergey Platonov
 
Smart Pointers in C++
Smart Pointers in C++Smart Pointers in C++
Smart Pointers in C++
Francesco Casalegno
 
C++ 11 Features
C++ 11 FeaturesC++ 11 Features
C++ 11 Features
Jan Rüegg
 
[C++] The Curiously Recurring Template Pattern: Static Polymorphsim and Expre...
[C++] The Curiously Recurring Template Pattern: Static Polymorphsim and Expre...[C++] The Curiously Recurring Template Pattern: Static Polymorphsim and Expre...
[C++] The Curiously Recurring Template Pattern: Static Polymorphsim and Expre...
Francesco Casalegno
 
C++ amp on linux
C++ amp on linuxC++ amp on linux
C++ amp on linux
Miller Lee
 
FTD JVM Internals
FTD JVM InternalsFTD JVM Internals
FTD JVM Internals
Felipe Mamud
 
An Embedded Error Recovery and Debugging Mechanism for Scripting Language Ext...
An Embedded Error Recovery and Debugging Mechanism for Scripting Language Ext...An Embedded Error Recovery and Debugging Mechanism for Scripting Language Ext...
An Embedded Error Recovery and Debugging Mechanism for Scripting Language Ext...
David Beazley (Dabeaz LLC)
 

What's hot (20)

C++ Code as Seen by a Hypercritical Reviewer
C++ Code as Seen by a Hypercritical ReviewerC++ Code as Seen by a Hypercritical Reviewer
C++ Code as Seen by a Hypercritical Reviewer
 
clWrap: Nonsense free control of your GPU
clWrap: Nonsense free control of your GPUclWrap: Nonsense free control of your GPU
clWrap: Nonsense free control of your GPU
 
Skiron - Experiments in CPU Design in D
Skiron - Experiments in CPU Design in DSkiron - Experiments in CPU Design in D
Skiron - Experiments in CPU Design in D
 
Summary of C++17 features
Summary of C++17 featuresSummary of C++17 features
Summary of C++17 features
 
HKG15-207: Advanced Toolchain Usage Part 3
HKG15-207: Advanced Toolchain Usage Part 3HKG15-207: Advanced Toolchain Usage Part 3
HKG15-207: Advanced Toolchain Usage Part 3
 
С++ without new and delete
С++ without new and deleteС++ without new and delete
С++ without new and delete
 
Tiramisu をちょっと、味見してみました。
Tiramisu をちょっと、味見してみました。Tiramisu をちょっと、味見してみました。
Tiramisu をちょっと、味見してみました。
 
Tensor comprehensions
Tensor comprehensionsTensor comprehensions
Tensor comprehensions
 
Дмитрий Нестерук, Паттерны проектирования в XXI веке
Дмитрий Нестерук, Паттерны проектирования в XXI векеДмитрий Нестерук, Паттерны проектирования в XXI веке
Дмитрий Нестерук, Паттерны проектирования в XXI веке
 
Exploring the Cryptol Toolset
Exploring the Cryptol ToolsetExploring the Cryptol Toolset
Exploring the Cryptol Toolset
 
Intel IPP Samples for Windows - error correction
Intel IPP Samples for Windows - error correctionIntel IPP Samples for Windows - error correction
Intel IPP Samples for Windows - error correction
 
Intel IPP Samples for Windows - error correction
Intel IPP Samples for Windows - error correctionIntel IPP Samples for Windows - error correction
Intel IPP Samples for Windows - error correction
 
GPU Programming on CPU - Using C++AMP
GPU Programming on CPU - Using C++AMPGPU Programming on CPU - Using C++AMP
GPU Programming on CPU - Using C++AMP
 
Gor Nishanov, C++ Coroutines – a negative overhead abstraction
Gor Nishanov,  C++ Coroutines – a negative overhead abstractionGor Nishanov,  C++ Coroutines – a negative overhead abstraction
Gor Nishanov, C++ Coroutines – a negative overhead abstraction
 
Smart Pointers in C++
Smart Pointers in C++Smart Pointers in C++
Smart Pointers in C++
 
C++ 11 Features
C++ 11 FeaturesC++ 11 Features
C++ 11 Features
 
[C++] The Curiously Recurring Template Pattern: Static Polymorphsim and Expre...
[C++] The Curiously Recurring Template Pattern: Static Polymorphsim and Expre...[C++] The Curiously Recurring Template Pattern: Static Polymorphsim and Expre...
[C++] The Curiously Recurring Template Pattern: Static Polymorphsim and Expre...
 
C++ amp on linux
C++ amp on linuxC++ amp on linux
C++ amp on linux
 
FTD JVM Internals
FTD JVM InternalsFTD JVM Internals
FTD JVM Internals
 
An Embedded Error Recovery and Debugging Mechanism for Scripting Language Ext...
An Embedded Error Recovery and Debugging Mechanism for Scripting Language Ext...An Embedded Error Recovery and Debugging Mechanism for Scripting Language Ext...
An Embedded Error Recovery and Debugging Mechanism for Scripting Language Ext...
 

Similar to DLL Design with Building Blocks

Using the android ndk - DroidCon Paris 2014
Using the android ndk - DroidCon Paris 2014Using the android ndk - DroidCon Paris 2014
Using the android ndk - DroidCon Paris 2014
Paris Android User Group
 
Getting started with the NDK
Getting started with the NDKGetting started with the NDK
Getting started with the NDK
Kirill Kounik
 
Android on IA devices and Intel Tools
Android on IA devices and Intel ToolsAndroid on IA devices and Intel Tools
Android on IA devices and Intel Tools
Xavier Hallade
 
Android ndk - Introduction
Android ndk  - IntroductionAndroid ndk  - Introduction
Android ndk - Introduction
Rakesh Jha
 
Android NDK
Android NDKAndroid NDK
Android ndk
Android ndkAndroid ndk
MattsonTutorialSC14.pptx
MattsonTutorialSC14.pptxMattsonTutorialSC14.pptx
MattsonTutorialSC14.pptx
gopikahari7
 
MattsonTutorialSC14.pdf
MattsonTutorialSC14.pdfMattsonTutorialSC14.pdf
MattsonTutorialSC14.pdf
George Papaioannou
 
Native Android for Windows Developers
Native Android for Windows DevelopersNative Android for Windows Developers
Native Android for Windows Developers
Yoss Cohen
 
Getting Native with NDK
Getting Native with NDKGetting Native with NDK
Getting Native with NDK
ナム-Nam Nguyễn
 
01 dll basics
01 dll basics01 dll basics
01 dll basics
Tsu-Fen Han
 
CNIT 126: 10: Kernel Debugging with WinDbg
CNIT 126: 10: Kernel Debugging with WinDbgCNIT 126: 10: Kernel Debugging with WinDbg
CNIT 126: 10: Kernel Debugging with WinDbg
Sam Bowne
 
Introduction to the Android NDK
Introduction to the Android NDKIntroduction to the Android NDK
Introduction to the Android NDK
BeMyApp
 
Advance Android Application Development
Advance Android Application DevelopmentAdvance Android Application Development
Advance Android Application Development
Ramesh Prasad
 
01 Introduction to programming
01 Introduction to programming01 Introduction to programming
01 Introduction to programming
maznabili
 
Introduction to Programming Lesson 01
Introduction to Programming Lesson 01Introduction to Programming Lesson 01
Introduction to Programming Lesson 01
A-Tech and Software Development
 
NDK Programming in Android
NDK Programming in AndroidNDK Programming in Android
NDK Programming in Android
Arvind Devaraj
 
CNIT 126: 10: Kernel Debugging with WinDbg
CNIT 126: 10: Kernel Debugging with WinDbgCNIT 126: 10: Kernel Debugging with WinDbg
CNIT 126: 10: Kernel Debugging with WinDbg
Sam Bowne
 
C++Basics2022.pptx
C++Basics2022.pptxC++Basics2022.pptx
C++Basics2022.pptx
Danielle780357
 
Ch 6: The Wild World of Windows
Ch 6: The Wild World of WindowsCh 6: The Wild World of Windows
Ch 6: The Wild World of Windows
Sam Bowne
 

Similar to DLL Design with Building Blocks (20)

Using the android ndk - DroidCon Paris 2014
Using the android ndk - DroidCon Paris 2014Using the android ndk - DroidCon Paris 2014
Using the android ndk - DroidCon Paris 2014
 
Getting started with the NDK
Getting started with the NDKGetting started with the NDK
Getting started with the NDK
 
Android on IA devices and Intel Tools
Android on IA devices and Intel ToolsAndroid on IA devices and Intel Tools
Android on IA devices and Intel Tools
 
Android ndk - Introduction
Android ndk  - IntroductionAndroid ndk  - Introduction
Android ndk - Introduction
 
Android NDK
Android NDKAndroid NDK
Android NDK
 
Android ndk
Android ndkAndroid ndk
Android ndk
 
MattsonTutorialSC14.pptx
MattsonTutorialSC14.pptxMattsonTutorialSC14.pptx
MattsonTutorialSC14.pptx
 
MattsonTutorialSC14.pdf
MattsonTutorialSC14.pdfMattsonTutorialSC14.pdf
MattsonTutorialSC14.pdf
 
Native Android for Windows Developers
Native Android for Windows DevelopersNative Android for Windows Developers
Native Android for Windows Developers
 
Getting Native with NDK
Getting Native with NDKGetting Native with NDK
Getting Native with NDK
 
01 dll basics
01 dll basics01 dll basics
01 dll basics
 
CNIT 126: 10: Kernel Debugging with WinDbg
CNIT 126: 10: Kernel Debugging with WinDbgCNIT 126: 10: Kernel Debugging with WinDbg
CNIT 126: 10: Kernel Debugging with WinDbg
 
Introduction to the Android NDK
Introduction to the Android NDKIntroduction to the Android NDK
Introduction to the Android NDK
 
Advance Android Application Development
Advance Android Application DevelopmentAdvance Android Application Development
Advance Android Application Development
 
01 Introduction to programming
01 Introduction to programming01 Introduction to programming
01 Introduction to programming
 
Introduction to Programming Lesson 01
Introduction to Programming Lesson 01Introduction to Programming Lesson 01
Introduction to Programming Lesson 01
 
NDK Programming in Android
NDK Programming in AndroidNDK Programming in Android
NDK Programming in Android
 
CNIT 126: 10: Kernel Debugging with WinDbg
CNIT 126: 10: Kernel Debugging with WinDbgCNIT 126: 10: Kernel Debugging with WinDbg
CNIT 126: 10: Kernel Debugging with WinDbg
 
C++Basics2022.pptx
C++Basics2022.pptxC++Basics2022.pptx
C++Basics2022.pptx
 
Ch 6: The Wild World of Windows
Ch 6: The Wild World of WindowsCh 6: The Wild World of Windows
Ch 6: The Wild World of Windows
 

More from Max Kleiner

EKON26_VCL4Python.pdf
EKON26_VCL4Python.pdfEKON26_VCL4Python.pdf
EKON26_VCL4Python.pdf
Max Kleiner
 
EKON26_Open_API_Develop2Cloud.pdf
EKON26_Open_API_Develop2Cloud.pdfEKON26_Open_API_Develop2Cloud.pdf
EKON26_Open_API_Develop2Cloud.pdf
Max Kleiner
 
maXbox_Starter91_SyntheticData_Implement
maXbox_Starter91_SyntheticData_ImplementmaXbox_Starter91_SyntheticData_Implement
maXbox_Starter91_SyntheticData_Implement
Max Kleiner
 
Ekon 25 Python4Delphi_MX475
Ekon 25 Python4Delphi_MX475Ekon 25 Python4Delphi_MX475
Ekon 25 Python4Delphi_MX475
Max Kleiner
 
EKON 25 Python4Delphi_mX4
EKON 25 Python4Delphi_mX4EKON 25 Python4Delphi_mX4
EKON 25 Python4Delphi_mX4
Max Kleiner
 
maXbox Starter87
maXbox Starter87maXbox Starter87
maXbox Starter87
Max Kleiner
 
maXbox Starter78 PortablePixmap
maXbox Starter78 PortablePixmapmaXbox Starter78 PortablePixmap
maXbox Starter78 PortablePixmap
Max Kleiner
 
maXbox starter75 object detection
maXbox starter75 object detectionmaXbox starter75 object detection
maXbox starter75 object detection
Max Kleiner
 
BASTA 2020 VS Code Data Visualisation
BASTA 2020 VS Code Data VisualisationBASTA 2020 VS Code Data Visualisation
BASTA 2020 VS Code Data Visualisation
Max Kleiner
 
EKON 24 ML_community_edition
EKON 24 ML_community_editionEKON 24 ML_community_edition
EKON 24 ML_community_edition
Max Kleiner
 
maxbox starter72 multilanguage coding
maxbox starter72 multilanguage codingmaxbox starter72 multilanguage coding
maxbox starter72 multilanguage coding
Max Kleiner
 
EKON 23 Code_review_checklist
EKON 23 Code_review_checklistEKON 23 Code_review_checklist
EKON 23 Code_review_checklist
Max Kleiner
 
EKON 12 Running OpenLDAP
EKON 12 Running OpenLDAP EKON 12 Running OpenLDAP
EKON 12 Running OpenLDAP
Max Kleiner
 
EKON 12 Closures Coding
EKON 12 Closures CodingEKON 12 Closures Coding
EKON 12 Closures Coding
Max Kleiner
 
NoGUI maXbox Starter70
NoGUI maXbox Starter70NoGUI maXbox Starter70
NoGUI maXbox Starter70
Max Kleiner
 
maXbox starter69 Machine Learning VII
maXbox starter69 Machine Learning VIImaXbox starter69 Machine Learning VII
maXbox starter69 Machine Learning VII
Max Kleiner
 
maXbox starter68 machine learning VI
maXbox starter68 machine learning VImaXbox starter68 machine learning VI
maXbox starter68 machine learning VI
Max Kleiner
 
maXbox starter67 machine learning V
maXbox starter67 machine learning VmaXbox starter67 machine learning V
maXbox starter67 machine learning V
Max Kleiner
 
maXbox starter65 machinelearning3
maXbox starter65 machinelearning3maXbox starter65 machinelearning3
maXbox starter65 machinelearning3
Max Kleiner
 
EKON22_Overview_Machinelearning_Diagrams
EKON22_Overview_Machinelearning_DiagramsEKON22_Overview_Machinelearning_Diagrams
EKON22_Overview_Machinelearning_Diagrams
Max Kleiner
 

More from Max Kleiner (20)

EKON26_VCL4Python.pdf
EKON26_VCL4Python.pdfEKON26_VCL4Python.pdf
EKON26_VCL4Python.pdf
 
EKON26_Open_API_Develop2Cloud.pdf
EKON26_Open_API_Develop2Cloud.pdfEKON26_Open_API_Develop2Cloud.pdf
EKON26_Open_API_Develop2Cloud.pdf
 
maXbox_Starter91_SyntheticData_Implement
maXbox_Starter91_SyntheticData_ImplementmaXbox_Starter91_SyntheticData_Implement
maXbox_Starter91_SyntheticData_Implement
 
Ekon 25 Python4Delphi_MX475
Ekon 25 Python4Delphi_MX475Ekon 25 Python4Delphi_MX475
Ekon 25 Python4Delphi_MX475
 
EKON 25 Python4Delphi_mX4
EKON 25 Python4Delphi_mX4EKON 25 Python4Delphi_mX4
EKON 25 Python4Delphi_mX4
 
maXbox Starter87
maXbox Starter87maXbox Starter87
maXbox Starter87
 
maXbox Starter78 PortablePixmap
maXbox Starter78 PortablePixmapmaXbox Starter78 PortablePixmap
maXbox Starter78 PortablePixmap
 
maXbox starter75 object detection
maXbox starter75 object detectionmaXbox starter75 object detection
maXbox starter75 object detection
 
BASTA 2020 VS Code Data Visualisation
BASTA 2020 VS Code Data VisualisationBASTA 2020 VS Code Data Visualisation
BASTA 2020 VS Code Data Visualisation
 
EKON 24 ML_community_edition
EKON 24 ML_community_editionEKON 24 ML_community_edition
EKON 24 ML_community_edition
 
maxbox starter72 multilanguage coding
maxbox starter72 multilanguage codingmaxbox starter72 multilanguage coding
maxbox starter72 multilanguage coding
 
EKON 23 Code_review_checklist
EKON 23 Code_review_checklistEKON 23 Code_review_checklist
EKON 23 Code_review_checklist
 
EKON 12 Running OpenLDAP
EKON 12 Running OpenLDAP EKON 12 Running OpenLDAP
EKON 12 Running OpenLDAP
 
EKON 12 Closures Coding
EKON 12 Closures CodingEKON 12 Closures Coding
EKON 12 Closures Coding
 
NoGUI maXbox Starter70
NoGUI maXbox Starter70NoGUI maXbox Starter70
NoGUI maXbox Starter70
 
maXbox starter69 Machine Learning VII
maXbox starter69 Machine Learning VIImaXbox starter69 Machine Learning VII
maXbox starter69 Machine Learning VII
 
maXbox starter68 machine learning VI
maXbox starter68 machine learning VImaXbox starter68 machine learning VI
maXbox starter68 machine learning VI
 
maXbox starter67 machine learning V
maXbox starter67 machine learning VmaXbox starter67 machine learning V
maXbox starter67 machine learning V
 
maXbox starter65 machinelearning3
maXbox starter65 machinelearning3maXbox starter65 machinelearning3
maXbox starter65 machinelearning3
 
EKON22_Overview_Machinelearning_Diagrams
EKON22_Overview_Machinelearning_DiagramsEKON22_Overview_Machinelearning_Diagrams
EKON22_Overview_Machinelearning_Diagrams
 

Recently uploaded

Gas agency management system project report.pdf
Gas agency management system project report.pdfGas agency management system project report.pdf
Gas agency management system project report.pdf
Kamal Acharya
 
22CYT12-Unit-V-E Waste and its Management.ppt
22CYT12-Unit-V-E Waste and its Management.ppt22CYT12-Unit-V-E Waste and its Management.ppt
22CYT12-Unit-V-E Waste and its Management.ppt
KrishnaveniKrishnara1
 
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Sinan KOZAK
 
Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...
Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...
Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...
shadow0702a
 
Null Bangalore | Pentesters Approach to AWS IAM
Null Bangalore | Pentesters Approach to AWS IAMNull Bangalore | Pentesters Approach to AWS IAM
Null Bangalore | Pentesters Approach to AWS IAM
Divyanshu
 
LLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by Anant
LLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by AnantLLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by Anant
LLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by Anant
Anant Corporation
 
学校原版美国波士顿大学毕业证学历学位证书原版一模一样
学校原版美国波士顿大学毕业证学历学位证书原版一模一样学校原版美国波士顿大学毕业证学历学位证书原版一模一样
学校原版美国波士顿大学毕业证学历学位证书原版一模一样
171ticu
 
Design and optimization of ion propulsion drone
Design and optimization of ion propulsion droneDesign and optimization of ion propulsion drone
Design and optimization of ion propulsion drone
bjmsejournal
 
CompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURS
CompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURSCompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURS
CompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURS
RamonNovais6
 
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
Yasser Mahgoub
 
VARIABLE FREQUENCY DRIVE. VFDs are widely used in industrial applications for...
VARIABLE FREQUENCY DRIVE. VFDs are widely used in industrial applications for...VARIABLE FREQUENCY DRIVE. VFDs are widely used in industrial applications for...
VARIABLE FREQUENCY DRIVE. VFDs are widely used in industrial applications for...
PIMR BHOPAL
 
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODELDEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
ijaia
 
一比一原版(CalArts毕业证)加利福尼亚艺术学院毕业证如何办理
一比一原版(CalArts毕业证)加利福尼亚艺术学院毕业证如何办理一比一原版(CalArts毕业证)加利福尼亚艺术学院毕业证如何办理
一比一原版(CalArts毕业证)加利福尼亚艺术学院毕业证如何办理
ecqow
 
Properties Railway Sleepers and Test.pptx
Properties Railway Sleepers and Test.pptxProperties Railway Sleepers and Test.pptx
Properties Railway Sleepers and Test.pptx
MDSABBIROJJAMANPAYEL
 
Embedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoringEmbedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoring
IJECEIAES
 
AI + Data Community Tour - Build the Next Generation of Apps with the Einstei...
AI + Data Community Tour - Build the Next Generation of Apps with the Einstei...AI + Data Community Tour - Build the Next Generation of Apps with the Einstei...
AI + Data Community Tour - Build the Next Generation of Apps with the Einstei...
Paris Salesforce Developer Group
 
Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...
Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...
Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...
IJECEIAES
 
Mechanical Engineering on AAI Summer Training Report-003.pdf
Mechanical Engineering on AAI Summer Training Report-003.pdfMechanical Engineering on AAI Summer Training Report-003.pdf
Mechanical Engineering on AAI Summer Training Report-003.pdf
21UME003TUSHARDEB
 
一比一原版(爱大毕业证书)爱荷华大学毕业证如何办理
一比一原版(爱大毕业证书)爱荷华大学毕业证如何办理一比一原版(爱大毕业证书)爱荷华大学毕业证如何办理
一比一原版(爱大毕业证书)爱荷华大学毕业证如何办理
nedcocy
 
AI for Legal Research with applications, tools
AI for Legal Research with applications, toolsAI for Legal Research with applications, tools
AI for Legal Research with applications, tools
mahaffeycheryld
 

Recently uploaded (20)

Gas agency management system project report.pdf
Gas agency management system project report.pdfGas agency management system project report.pdf
Gas agency management system project report.pdf
 
22CYT12-Unit-V-E Waste and its Management.ppt
22CYT12-Unit-V-E Waste and its Management.ppt22CYT12-Unit-V-E Waste and its Management.ppt
22CYT12-Unit-V-E Waste and its Management.ppt
 
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
 
Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...
Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...
Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...
 
Null Bangalore | Pentesters Approach to AWS IAM
Null Bangalore | Pentesters Approach to AWS IAMNull Bangalore | Pentesters Approach to AWS IAM
Null Bangalore | Pentesters Approach to AWS IAM
 
LLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by Anant
LLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by AnantLLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by Anant
LLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by Anant
 
学校原版美国波士顿大学毕业证学历学位证书原版一模一样
学校原版美国波士顿大学毕业证学历学位证书原版一模一样学校原版美国波士顿大学毕业证学历学位证书原版一模一样
学校原版美国波士顿大学毕业证学历学位证书原版一模一样
 
Design and optimization of ion propulsion drone
Design and optimization of ion propulsion droneDesign and optimization of ion propulsion drone
Design and optimization of ion propulsion drone
 
CompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURS
CompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURSCompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURS
CompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURS
 
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
 
VARIABLE FREQUENCY DRIVE. VFDs are widely used in industrial applications for...
VARIABLE FREQUENCY DRIVE. VFDs are widely used in industrial applications for...VARIABLE FREQUENCY DRIVE. VFDs are widely used in industrial applications for...
VARIABLE FREQUENCY DRIVE. VFDs are widely used in industrial applications for...
 
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODELDEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
 
一比一原版(CalArts毕业证)加利福尼亚艺术学院毕业证如何办理
一比一原版(CalArts毕业证)加利福尼亚艺术学院毕业证如何办理一比一原版(CalArts毕业证)加利福尼亚艺术学院毕业证如何办理
一比一原版(CalArts毕业证)加利福尼亚艺术学院毕业证如何办理
 
Properties Railway Sleepers and Test.pptx
Properties Railway Sleepers and Test.pptxProperties Railway Sleepers and Test.pptx
Properties Railway Sleepers and Test.pptx
 
Embedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoringEmbedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoring
 
AI + Data Community Tour - Build the Next Generation of Apps with the Einstei...
AI + Data Community Tour - Build the Next Generation of Apps with the Einstei...AI + Data Community Tour - Build the Next Generation of Apps with the Einstei...
AI + Data Community Tour - Build the Next Generation of Apps with the Einstei...
 
Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...
Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...
Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...
 
Mechanical Engineering on AAI Summer Training Report-003.pdf
Mechanical Engineering on AAI Summer Training Report-003.pdfMechanical Engineering on AAI Summer Training Report-003.pdf
Mechanical Engineering on AAI Summer Training Report-003.pdf
 
一比一原版(爱大毕业证书)爱荷华大学毕业证如何办理
一比一原版(爱大毕业证书)爱荷华大学毕业证如何办理一比一原版(爱大毕业证书)爱荷华大学毕业证如何办理
一比一原版(爱大毕业证书)爱荷华大学毕业证如何办理
 
AI for Legal Research with applications, tools
AI for Legal Research with applications, toolsAI for Legal Research with applications, tools
AI for Legal Research with applications, tools
 

DLL Design with Building Blocks

  • 1. DLL Building Blocks Yes, we scan… http://en.wikipedia.org/wiki/Web_of_Things Max Kleiner Script: 362_maxon3D_EKON18.TXT
  • 2. Agenda and Tutorial (DLL 32/64 bit) 2 http://www.softwareschule.ch/download/maxbox_starter28.pdf • Call a DLL • Call a DLL+ (Interface, Callback, Events) • Build a DLL • Recompile a DLL • Android NDK and Lazarus http://scholz2000.com/ 136_sysinformation_dll_EKON1.txt A Short History of Time 1991 Application Program 1995 Application 1998 Applet 2010 App 2015 A (Scholz2000, Android, Arduino, ARM)
  • 3. DLL Primer •• Call: If you want your library to be called from programs compiled with other compilers, it is important to specify the correct calling convention. •• Create: A library can be created just as a program, only it uses the library keyword, and it has an exports section. •• Let's get back to the topic and create a DLL callback function: •• 1. declare a function type • 2. the function itself • 3. define the DLL reference • 4. then implement the function in the client • 5. and call the DLL: 3 136_sysinformation_dll_EKON1.txt 039_pas_dllcall_EKON2.txt 070_pas_functionplotter_digital2.txt
  • 4. CCaallllbbaacckk hhaacckk ssttaacckk • 4 Callback example in client unit 136_Callback_dll_EKON6.txt ----------------------------------------------- interface... 1. TCallBackFunction = function(sig: integer):boolean; 2. function callME(sig: integer):boolean; implement... 3. procedure TestCallBack(myCBFunction: TCallBackFunction); register; external('watchcom.dll'); 4. function callMe(sig: integer): boolean; begin {whatever you need to do, case of...} showmessage('I was called with'+ inttostr(sig)); end; 5. procedure TForm1.Button1Click(sender: TObject); begin testCallBack(callMe); //subscribe function in DLL end;
  • 5. Create a DLL 5 Callback in the DLL In the DLL you would also declare a function type and a procedure (or function) itself, so use it like this: type TCallBackFunction = function(sig: integer):boolean; procedure TestCallBack(clientFunc: TCallBackFunction); stdcall; var sigAlive: boolean; begin {timer stuff... set the signal...} if(clientFunc(55)) then sigalive := true; end; exports TestCallBack;
  • 6. http://max.kleiner.com/dllplus.htm 6 Export an object-reference from a DLL is one approach to get real OO-access to a DLL. The DLL must create and return the object, so the client gets the methods without encapsulating. unit income1; interface type IIncome = class public function GetIncome(const aNetto: Currency): Currency; virtual; abstract; procedure SetRate(const aPercent, aYear: integer); virtual; abstract; function queryDLLInterface(var queryList: TStringList): TStringList; virtual; abstract; end; 036_pas_includetest_EKON3.txt 036_pas_dynlib_EKON4.txt 036_pas_DLLTesting_EKON5.tx
  • 7. Solution FPC ELF32 shared object 7 32-bit EXE loads 32-bit DLL, 64-bit EXE loads 64-bit DLL. ************* Simple Sequence Diagram************** Client DLL ¦ TestCallBack(clientFunc) ¦ ¦---------------------------------------------->¦ ¦ clientFunc.callMe(sig ) ¦ ¦<----------------------------------------------¦ ¦ ¦ ¦ true (or something to return) ¦ ¦---------------------------------------------->¦ ¦ ¦ http://wiki.freepascal.org/Android_Programming http://www.softwareschule.ch/examples/440_DLL_Tutor2.txt Tutor: http://www.softwareschule.ch/download/maxbox_starter18_3.pdf
  • 8. Solution NDK The NDK is a toolset that allows you to implement parts of your app using native-code languages such as C, Pascal, Object Pascal and C++. For certain types of apps, this can be helpful so you can reuse existing code libraries written in these languages, but most apps do not need the Android NDK. Typical good candidates for the NDK are CPU-intensive workloads such as game engines, signal processing, physics simulation, and so on. When examining whether or not you should develop in native code, think about your requirements and see if the Android framework APIs provide the functionality that you need. You have to use the Android NDK to recompile the library. The ARM architecture is completely different from the x86 architecture. The system calls are different on Linux and Windows. 8 http://www.ntu.edu.sg/home/ehchua/programming/android/android_ndk.html
  • 9. NDK Need Things If you have the src files for the DLL, try recompiling as an ELF32 shared object, then link that instead into your Android code (- below is a Windows solution): set NDK_HOME=C:Androidandroid-ndk-r9c // customize this var for your own location set LD_LIBRARY_PATH=%NDK_HOME%platformsandroid-18arch-armusrlib cd REM -- TEMPORARILY COPY SOME LIBS COMPILER MAY NEED copy %NDK_HOME%platformsandroid-18arch-armusrlibcrtbegin*.o . copy %NDK_HOME%platformsandroid-18arch-armusrlibcrtend*.o . REM -- GENERATE YOUR OBJ FILE %NDK_HOME%toolchainsarm-linux-androideabi-4.8prebuiltwindows-x86_64binarm-linux-androideabi- gcc.exe -g -I%NDK_HOME%platforms android-18arch-armusrinclude -c -fPIC YourLib.c -o YourLib.o REM -- GENERATE SHARED OBJ FROM OBJ FILE %NDK_HOME%toolchainsarm-linux-androideabi-4.8prebuiltwindows-x86_64binarm-linux-androideabi- gcc.exe -g -L%NDK_HOME%platforms android-18arch-armusrlib -shared -o YourLib_so.so YourLib_so.o REM -- finally, remove the libraries previously copied to src directory del .crtbegin*.o del .crtend*.o 9
  • 10. Optional: Create <project>/jni/Application.mk. Build your native code by running the 'ndk-build' script from your project's directory. It is located in the top-level NDK directory: cd <project> <ndk>/ndk-build I discovered that to use the build-ndk script, I don't need a real project. I created a folder project, with nothing in it except another folder jni, and put all my sources in that folder. I then created the Android.mk file and ran the script as described in the ndk docs. 10 Here's the general outline of how you work with the NDK tools: Place your native sources under <project>/jni/... Create <project>/jni/Android.mk to describe your native sources to the NDK build system http://developer.android.com/sdk/ndk/index.html
  • 11. Thanks! Links to Blocks the source is the code http://www.softwareschule.ch/maxbox.htm http://sourceforge.net/projects/maxbox http://en.wikipedia.org/wiki/Arduino http://www.softwareschule.ch/download/webofthings2013.pdf Book Patterns konkret http://www.amazon.de/Patterns-konkret-Max-Kleiner/dp/3935042469 maXbox https://github.com/maxkleiner/maXbox3/releases 11 http://max.kleiner.com/dllplus.htm http://www.softwareschule.ch/download/dlldesign_ekon9.pdf http://developer.android.com/sdk/ndk/index.html http://www.ntu.edu.sg/home/ehchua/programming/android/android_ndk.html
  • 12. Questions? Code a World hack the earth 12 Yes, we hack… https://github.com/maxkleiner/maXbox3/releases