Saturday, 2 March 2013

Visual Studio - Creating and Using a dll anf lib library

link reference
1 : To create a new dll file
      Picture 1 :From the File menu, select New and then Project….
Picture 2 :From the Project types pane, under Visual C++..... .  Name:example
Picture 3 :
Picture 4 :
Picture 5 :
Picture 6:
Picture 7:
Picture 8:To add a class to the dynamic link library
2 : To use  the dll file
Picture 9:To create an application that will reference and use the dynamic link library that was just created
Picture 10 :
Picture 11 :
Picture 12 :
Picture 13 :
Picture 14:
Picture 15
Picture 16:
Picture 17:
Picture 18 :
Picture 19 

Static lib :click Here




Difference Between LIB and DLL


                     (resoure  :http://www.differencebetween.net)
        LIB vs DLL
When developing software, we are often asked whether we want to use LIB or DLLs in containing functions for the application. LIB is a static library where functions and procedures can be placed and called as the application is being compiled. A DLL or Dynamic Link Library does the same function but is dynamic in a sense that the application can call these libraries during run-time and not during the compilation. This presents a few significant advantages compared to using LIB.
For starters, you would have a single file that is significantly bigger as it contains all of the code while you would have multiple smaller files when using DLL. Compiling your functions and procedures would also allow you more reusability as once you are happy with the functions on the DLL because you can keep it as is with each version of the application and not have to mess with it. You can also use the same DLL if you want to create another application that uses the same functions and procedures. You can directly link to the DLL rather than copy the code from the source as you would need to do with LIB.
A problem with DLL is when you change the content of the DLL. This can lead to versioning problems where an application uses the incorrect version of the DLL causing problems. You need to keep track of your DLLs in order to avoid these problems. You would not have this problem with LIB as you would only get one large file.
choosing DLL, you would still have a LIB file in your project. But unlike when using LIB, this file does not contain the code of the functions and procedures but only stubs that the program needs to call the procedures from the DLL’s.
Summary:
1. A DLL is a library that contains functions that can be called by applications at run-time while LIB is a static library whose code needs to be called during the compilation
2. Using LIB would result in a single file that is considerable bigger while you end up with multiple smaller files with DLL’s
3. DLL’s are more reusable than LIBs when writing new versions or totally new applications
4. DLL files can be used by other applications while LIB files cannot
5. DLL’s are prone to versioning problems while LIB is not
6.  You would still have a LIB file when developing software with DLLs but it only contains stubs

                                                                                                 ThongLT

No comments:

Post a Comment