Command Line Dynamic Library

Here is the complete documentation on creating and using a dynamic linking library on the command line.

What is a Dynamic Linking Library (DLL) ?

A DLL is a module that contains fiunctions and data that can be used by another module. A DLL helps reduce memory overhead when several applications use the same functionality at the same time, since although each application receives its own copy of the DLL data, the applications share the DLL code.

Here's how to create your own DLL from the command line:

(a)  Create a project (ComplexLibrary, say) and create two files in it. The first file is a header file (.h) which contains the prototypes of the members of the class(Comp.h, say). The second file is a .cpp file (ComplexLibrary.cpp, say) which contains the  definitions of members in Comp.h.

(b)  On the command line, use the command : $g++ -c ComplexLibrary.cpp –shared –o ComplexDynamic.dll to  build the project and create the dynamic linking library (.dll) file. On Unix based systems, use $g++ -c ComplexLibrary.cpp –shared –o

(c)  Create a new project, and create a single file, Main.cpp, which will use the dynamic linking library that we have created. Copy ComplexDynamic.dll (or as well as Comp.h into the project where we created Main.cpp.

(d)  Use #include “Complex.h” in Main.cpp to use the complex class.

(e)  On the command line, use the following command to link the dynamic linking library and build Main.cpp :
                                   $g++ Main.cpp -I. -L. –lComplexDynamic –o Main

(f)  This would have created the executable Main.exe file.


Popular posts from this blog

Creating a Mail Server Using Webmin

Quick-Start a Springboot Project

Creating a Maven Web-Service in IntelliJ