Building NetWare DLLs
Articles and Tips: article
01 Sep 1998
Builds on a previous article which introduced the NetWare DLL loader. Describes the DLL SDK and helps you understand the components of NetWare DLLs as well as how to build them using Borland and Microsoft compilers.
In the last issue of Developer Notes we were introduced to the NetWare DLL loader. This technology is available in NetWare 5 and is soon to be released for NetWare 4.11. As a brief overview, the NetWare DLL loader allows NetWare to recognize and load special NetWare DLL modules. A NetWare DLL is similar to an NLM and is built with the same source code, yet it can be built with standard Borland and Microsoft compilers, allowing developers to use their existing development environment.
This article will describe the DLLSDK and help you understand the components of NetWare DLLs as well as how to build them using Borland and Microsoft compilers.
The DLLSDK is a collection of header files, libraries, sample code, tutorials, and documentation. It is not designed to be a standalone SDK but a subset or a companion to the NetWare SDK (release 14 or greater). By the next major release, the DLLSDK will be integrated into the NetWare SDK.
The Beta version of the DLLSDK is available at: http://developer.novell.com/devres/dllenv.
Installation of the DLLSDK is performed by executing the self- extracting file, preferably at the root of C:. (Installing the DLLSDK at the root of C: eliminates the need to modify the path to the SDK in the sample makefiles.) Of course, the DLLSDK can be installed wherever you prefer. When the DLLSDK.EXE file is executed, it creates a DLLSDK directory where it places the SDK components.
The header files contained in the DLLSDK are mostly a modified subset of the header files contained in the NetWare SDK, with a few exceptions. These header files should be used in place of the NWSDK header files, so you will notice that the examples include the DLLSDK header directory before any NWSDK header directories. There are some new header files that will be discussed in future versions of the DLLSDK. These are mainly, but not exclusively, for localization of NetWare DLLs.
Two sets of libraries are provided, OMF (Borland - BC) and COFF (Microsoft - VC). These libraries are used similar to Import (.IMP) files, to resolve external symbol references, as well as to assure that dependent modules are loaded. These libraries are linked into your project.
Various tools are provided to view and manipulate the resultant NetWare DLLs. These tools are described in detail in the DLLSDK documentation.
Two example programs are included in the DLLSDK, both being presented with Makefile (command-line) and IDE project examples.
The DLLSDK documentation is one HTML file which describes in detail the entire process of building a NetWare DLL, as well as other useful information about NetWare DLLs.
Components of a NetWare DLL
Components of a NetWare DLL include the following:
The source code for a NetWare DLL is the same as the source for an NLM. An exception to this rule is for localization, which can be accomplished using Windows DLL style methods and procedures. Localization will be discussed in later versions of the DLLSDK, or for the adventurous, see PEDLL.H for localization prototypes.
Header files (.h)
Be sure your makefile or include paths list the DLLSDK include directory before any NWSDK include directories. This is demonstrated in the sample makefiles and IDE project examples in the DLLSDK.
Libraries (.obj, .lib)
The libraries you link into your DLL depend on the development environment you are using, Borland or Microsoft, and what NetWare APIs you are using.
The minimum libraries for Borland compilers are:
C0NW.OBJ and CNW.LIB.
The object file is Borland startup code, and the library is the stub equivalent of CLIB.IMP.
For Microsoft compilers, the startup code and CLIB.IMP stubs are all contained in: LIBC.LIB.
All other libraries contain the same stubs as their .IMP equivalents. (See DLLSDK\LIB\IMPORTS directory and the DLLSDK documentation)
You may also create your own .LIB files using the IMP2LIB.EXE utility provided with the DLLSDK.
The resource file uses the same format as a Windows resource file. It contains information such as stack size, version info, screen- name, thread-name, internal module name, etc. The samples are designed so you can just fill in the blanks (or change default values).
The definition file is optional and may contain information about exported symbols, among other things. Other definition file options will be discussed in later versions of the DLLSDK.
Building the Hello World Example with make
Once the DLLSDK is installed, change into the directory:
Edit MAKEFILE.xC (BC for Borland, VC for Microsoft) and check the DLLSDK, NWSDK, BC and/or VC macros for the proper paths in your environment.
You are now ready to build the NetWare DLL.
Borland C++ 5.02 (make)
make /f makefile.bc /r
The DLL will be placed in the BC directory.
Microsoft Visual C++ (nmake)
nmake /f makefile.vc
The DLL will be placed in the VC directory.
If you prefer working with a visual development environment, the DLLSDK also contains sample IDE projects for both compilers.
See dllsdk\examples\envidefor details.
Loading a NetWare DLL
Currently, NetWare DLLs can only be loaded on NetWare 5 Beta 3 and later. By the end of summer, a patch will be available for NetWare 4.11 w/Support Pack 5 to allow NetWare DLL loading.
Loading a NetWare DLL requires the loader extension to be registered with the OS. This needs to be done only once after the server is up, so it may be placed in the AUTOEXEC.NCF.
Loading a NetWare DLL is similar to loading an NLM but requires that the extension be specified.
Note: The LOAD keyword is optional in NetWare 5.
If you need to unregister the loader extension do:
Note: PELDR.NLM registers the loader extension with the OS, loads the PEDLL.DLL library, then unloads. This is why PELDR.NLM doesn't show up in the modules list after it is loaded and active. PEDLL.DLL does appear in the modules list however, indicating that the PE (DLL) Loader is registered. When PEDLL.DLL is unloaded, it unregisters the loader extension before terminating.
NetWare DLLs give you, the developer, a means whereby you can easily develop NetWare modules with Borland or Microsoft development environments. Soon to be integrated into the NetWare SDK, the Beta release of the DLLSDK is currently available to guide you through NetWare DLL development process. Technical assistance is available on the developer newsgroups at http://developer.novell.com in the beta.netware5 forum.
* Originally published in Novell AppNotes
The origin of this information may be internal or external to Novell. While Novell makes all reasonable efforts to verify this information, Novell does not make explicit or implied claims to its validity.