Saves memory and reduces swapping No recompilation on changes A DLL can provide after-market support Programs written in different languages can call the.

Slides:



Advertisements
Similar presentations
Introduction to Eclipse. Start Eclipse Click and then click Eclipse from the menu: Or open a shell and type eclipse after the prompt.
Advertisements

CS 11 C track: lecture 7 Last week: structs, typedef, linked lists This week: hash tables more on the C preprocessor extern const.
Programming In C++ Spring Semester 2013 Lecture 11 Programming In C++, Lecture 11 By Umer Rana.
Introduction to Linked Lists In your previous programming course, you saw how data is organized and processed sequentially using an array. You probably.
Ceng-112 Data Structures I 1 Chapter 3 Linear Lists.
Data Structures: A Pseudocode Approach with C 1 Chapter 5 Contd... Objectives Explain the design, use, and operation of a linear list Implement a linear.
© 2004, D. J. Foreman 1 Program Linking. © 2004, D. J. Foreman 2 Program Content  Given the following file: Float Mysqrt(float); void Prog1 () { extern.
Copyright © 2008 Pearson Addison-Wesley. All rights reserved. Chapter 12 Separate Compilation Namespaces Simple Make Files (Ignore all class references.
Software Language Levels Machine Language (Binary) Assembly Language –Assembler converts Assembly into machine High Level Languages (C, Perl, Shell)
Lab2 TA Notes. Set up for Visual C++ New Workspace Win32 Console Application – This runs from a command line Chose Blank Project Add your.C file Build.
COMP1170 Midterm Preparation (March 17 th 2009) Acknowledgment The notes are adapted from those provided by Deitel & Associates, Inc. and Pearson Education.
Here’s how to start the Microsoft Visual C++ program; click on start, then programsclick on start, then programs Choose Microsoft Visual C++ or Microsoft.
Computer Science 210 Computer Organization Modular Decomposition Making a Library Separate Compilation.
The Preprocessor #include #define N 10 C program Preprocessor Modified C program Preprocessor Object codes.
Functions in C. Function Terminology Identifier scope Function declaration, definition, and use Parameters and arguments Parameter order, number, and.
C++ / G4MICE Course Session 3 Introduction to Classes Pointers and References Makefiles Standard Template Library.
Programming Languages and Paradigms Object-Oriented Programming.
C++ Programming: Program Design Including Data Structures, Fourth Edition Chapter 13: Pointers, Classes, Virtual Functions, and Abstract Classes.
C++ Programming: From Problem Analysis to Program Design, Fourth Edition Chapter 14: Pointers, Classes, Virtual Functions, and Abstract Classes.
Computing IV Visual C Introduction with OpenCV Example Xinwen Fu.
Recap, Test 1 prep, Composition and Inheritance. Dates Test 1 – 12 th of March Assignment 1 – 20 th of March.
9 Chapter Nine Compiled Web Server Programs. 9 Chapter Objectives Learn about Common Gateway Interface (CGI) Create CGI programs that generate dynamic.
The Structure of a C++ Program. Outline 1. Separate Compilation 2. The # Preprocessor 3. Declarations and Definitions 4. Organizing Decls & Defs into.
Java Introduction to JNI Prepared by Humaira Siddiqui.
By Noorez Kassam Welcome to JNI. Why use JNI ? 1. You already have significantly large and tricky code written in another language and you would rather.
Win32 Programming Lesson 20: Advanced DLL Techniques.
Linking and Loading Linker collects procedures and links them together object modules into one executable program. Why isn't everything written as just.
February 11, 2005 More Pointers Dynamic Memory Allocation.
ITEC 352 Lecture 18 Functions in Assembly. Functions + Assembly Review Questions? Project due on Friday Exam –Average 76 Methods for functions in assembly.
Stack and Heap Memory Stack resident variables include:
Our Environment We will exercise on Microsoft Visual C++ v.6 We will exercise on Microsoft Visual C++ v.6 because that is what we have in the univ. because.
Lecture 11 Dynamic link libraries. Differences between static libraries and DLLs In static library code is added to the executable. In DLL, the code is.
Programming with Visual C++ A short review of the process.
MICHALIS POLYCHRONAKIS(COLUMBIA UNIVERSITY,USA), KOSTAS G. ANAGNOSTAKIS(NIOMETRICS, SINGAPORE), EVANGELOS P. MARKATOS(FORTH-ICS, GREECE) ACSAC,2010 Comprehensive.
Module 6: Debugging a Windows CE Image.  Overview Debug Zones IDE Debug Setup IDE Debug Commands Platform Builder Integrated Kernel Debugger Other Debugging.
© Janice Regan, CMPT 300, May CMPT 300 Introduction to Operating Systems Memory: Relocation.
Programming with Visual Studio.NET A short review of the process.
111 Introduction to OGRE3D Programming: Main Loop.
Dynamic Link Libraries: Inside Out. Dynamic Link Libraries  About Dynamic-Link Libraries  Dynamic-Link Libraries Hands On  Dynamic Link Library Reference.
Writing a Run Time DLL The application loads the DLL using LoadLibrary() or LoadLibraryEx(). The standard search sequence is used by the operating system.
Nyhoff, ADTs, Data Structures and Problem Solving with C++, Second Edition, © 2005 Pearson Education, Inc. All rights reserved Stacks.
15. WRITING LARGE PROGRAMS. Source Files A program may be divided into any number of source files. Source files have the extension.c by convention. Source.
 2003 Prentice Hall, Inc. All rights reserved. 1 IS 0020 Program Design and Software Tools Preprocessor Midterm Review Lecture 7 Feb 17, 2004.
CPS120: Introduction to Computer Science Compiling a C++ Program From The Command Line.
1 How to Install OpenGL u Software running under Microsoft Windows makes extensive use of "dynamic link libraries." A dynamic link library (DLL) is a set.
Separating Class Specification tMyn1 Separating Class Specification from Implementation Usually class declarations are stored in their own header files.
Win32 Programming Lesson 19: Introduction to DLLs.
Visual Basic Integrated Development Environment (IDE) 56:150 Information System Design.
The Development Process Compilation. Compilation - Dr. Craig A. Struble 2 Programming Process Problem Solving Phase We will spend significant time on.
1 Object-Oriented Programming -- Using C++ Andres, Wen-Yuan Liao Department of Computer Science and Engineering De Lin Institute of Technology
Program Libraries 1. What is a program library? A library is a collection of implementations of behavior, written in terms of a language, that has a well-defined.
Evolution of C and C++ n C was developed by Dennis Ritchie at Bell Labs (early 1970s) as a systems programming language n C later evolved into a general-purpose.
Introduction to Computer Programming Concepts M. Uyguroğlu R. Uyguroğlu.
Python C API overview References:
Binding & Dynamic Linking Presented by: Raunak Sulekh(1013) Pooja Kapoor(1008)
1 Data Structures and Algorithms Stack. 2 The Stack ADT Introduction to the Stack data structure Designing a Stack class using dynamic arrays Linked Stacks.
(1-3) Basics of a Linked List I Instructor - Andrew S. O’Fallon CptS 122 (June 9, 2016) Washington State University.
Function: Declaration
INC 161 , CPE 100 Computer Programming
C Basics.
Quick Start Guide for Visual Studio 2010
TCL command in C, a simple example Nguyen Truong – GCS VN Aug 5, 2004
User Defined Functions
Dynamic Link Libraries (DLL)
CON2D Compile Procedure Using Visual FROTRAN 6.6
1. Open Visual Studio 2008.
C Preprocessor(CPP).
ms vısual studıo 2008-Introductıon TUTORIAL
Comments, Prototypes, Headers & Multiple Source Files
What Is? function predefined, programmer-defined
Presentation transcript:

Saves memory and reduces swapping No recompilation on changes A DLL can provide after-market support Programs written in different languages can call the same DLL functions Advantages of Dynamic Linking

Run Time Dynamic Linking Loaded using LoadLibrary or LoadLibraryEx Standard search sequence will be used to locate DLLs. Two DLLs that have the same base file name and extension but are found in different directories are not considered to be the same DLL. If the system cannot find the DLL or if the entry-point function returns FALSE, LoadLibrary or LoadLibraryEx returns NULL. The process can use GetProcAddress to get the address of an exported function in the DLL using a DLL module handle returned by either LoadLibrary, LoadLibraryEx, or GetModuleHandle

Run Time Dynamic Linking When the DLL module is no longer needed, the process can call FreeLibrary or FreeLibraryAndExitThread. Run-time dynamic linking enables the process to continue running even if a DLL is not available.

Using Run Time Loading  Add a new “Win32 Console Application” project with name “UsingRunTimeDLL” to the workspace “DLLsTraining”.  Choose an empty project  Add a new file named “UsingRunTimeDLL.cpp”.  Add code shown below to “UsingRunTimeDLL.cpp”

Using Run Time Loading UsingRunTimeDLL.cpp #include int main() { // Load the run time DLL and ask for the address of the exported function. // It is always advised to check the return values of the calls, as it is quite // possible to get the NULL pointers as return values. HMODULE runTimeDLLHandle = LoadLibrary(TEXT("RunTimeDll.DLL")); if(runTimeDLLHandle == NULL) { MessageBox(NULL, TEXT("Failed to load the DLL"), TEXT("Error"), MB_OK ); return 0 ; }

Using Run Time Loading else { // Define a user define Function Pointer type. This type will vary from the // function to function depending on their return types and parameters list. typedef void (*MyProc)(); // Query for the address of the function “SayRuntimeLoadDLL” MyProc runtimeDLLFn = (MyProc)GetProcAddress(runTimeDLLHandle, TEXT("SayRuntimeLoadDLL")); if( NULL == runtimeDLLFn ) { MessageBox(NULL, TEXT("SayRunTimeDLL function not exposed."), TEXT("Error"), MB_OK ); return 0 ; } runtimeDLLFn (); } return 1 ; }

Creating A RunTime DLL  Add a new “Win32 Dynamic-Link Library” project with name “RunTimeDLL” to the workspace “DLLsTraining”.  Choose an empty DLL project  Add a new file named “RunTimeDLL.cpp”, “RunTimeDLL.h” and “RunTimeDLL.def” to RunTimeDLL project.  Add code shown below to “RunTimeDLL.cpp” and “RunTimeDLL.h”

Creating A RunTime DLL RunTimeDLL.cpp #include #include "RunTimeDLL.h" // Definition of the function which will be exported to other modules. void SayRunTimeDLL() { MessageBox( NULL, TEXT("I am a run time DLL"), TEXT(“Information"), MB_OK ); }

Creating A RunTime DLL RunTimeDLL.h // Add the include guards to protect from cyclic an redundant inclusions #ifndef _RUN_TIME_DLL_H #define _RUN_TIME_DLL_H // Here the function will be exported using.def file. So no need to export using the // declspec. This is the way to export the function from an dll that can be loaded at // runtime and asked for the addresses of the function. void SayRunTimeDLL() ; #endif

Creating A RunTime DLL –RunTimeDLL.def LIBRARY "RunTimeDLL" EXPORTS SayRuntimeDLL

Creating A RunTime DLL  Compile the project RunTimeDLL. The out put would be: Configuration: RunTimeDLL - Win32 Debug Compiling... RunTimeDLL.cpp Linking... Creating library Debug/RunTimeDLL.lib and object Debug/RunTimeDLL.exp RunTimeDLL.dll - 0 error(s), 0 warning(s)  If the generation of “RunTimeDLL.lib” is absent, it means no functions were exported and DLL cannot be loaded or used.  (To test change the name of the SayRunTimeDLL to SayRunTimeDll in.def file. Observe case.)