April 18, 2024, 07:47:56 PM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


8. Dynamic Link or Static Library

Started by LarryMc, August 14, 2011, 04:17:45 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

LarryMc

When you are finished with your custom control creation you will more than likely want to share it with others.  There are basically three ways to package your creation for sharing. Note: This discussion has no bearing in whether you sell or give it away.

First, you can share the raw source code.  That is ultimately what is being done with this tutorial.  But then again, it would be rather difficult to do a tutorial on creating a custom control without showing the code.  However, I have a hidden agenda.  I'm hoping this tutorial will encourage one or more brave programmer's to create something unique and/or useful.

Normally, a custom control is shared in the form of a library. Okay; what's a library.  A library is simply a collection of compiled source file subroutines.  It may also contain some variables that are global to the code in the library.  During development, the source code that will eventually be in the library is no different then the code you would write for any other program you create in IWBasic.

You decide to go with the norm and share your control with a library.  But you're not done with making this decision. Are you going to use a dynamic link library (DLL) or a static library (LIB).

Both types of libraries contain your compiled source code.  IWBasic is capable of creating either type.  The big difference is how they are used by the people you share with.

A static library is used only by a programmer when they are creating an application.  When they compile their application the object modules inside your library are copied (linked)  into their application.  In turn, the user of their application never really knows your static library exists.  You already use static libraries every time you compile a project in IWBasic without even knowing it.

With a dynamic link library, the programmer has to first create a linking library from the dynamic library.  This linking library doesn't contain any of your original compiled object files.  It only contains information that identifies your DLL and the addresses of all the subroutines/functions in your DLL that are available for the programmer to use in creating their application.  When the programmer distributes their application they have to also distribute your DLL along with it.  That is because your object code is only loaded into memory to be executed at run time.  You also use DLL's every time you compile a program now that uses a IWBasic command that in turn uses one of the functions in the OS's DLLs.

To me, a static lib is the simplest and cleanest to use; for you while you are creating it, for the programmer's you share it with, and for the user's of their applications that use your library.

In this tutorial we will be creating our custom control and sharing it as a static library.

_____________________________

Coming Next - Development Environment
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library