For one reason or another you may find yourself with a Linux shared library that you want to use as if it was a Windows Dll. There are various reasons for this including the following:
You are porting a large application that uses several third-party libraries. One is available on Linux but you are not yet ready to link to it directly as a Linux shared library.
(The ODBC interface in WINE). There is a well-defined interface available and there are several Linux solutions that are available for it.
The process for dealing with these situations is actually quite simple. You need to write a spec file that will describe the library's interface in the same format as a Dll (primarily what functions it exports). Also you will want to write a small wrapper around the library. We combine these to form a Wine builtin Dll that links to the Linux library.
In this section we will look at two examples. The first example is extremely simple and leads into the subject in "baby steps". The second example is the ODBC interface proxy in Wine. The files to which we will refer for the ODBC example are currently in the dlls/odbc32 directory of the Wine source.
The first example is based very closely on a real case (the names of the functions etc. have been changed to protect the innocent). A large Windows application includes a DLL that links to a third-party DLL. For various reasons the third-party DLL does not work too well under Wine. However the third-party DLL is also available for the Linux environment. Conveniently the DLL and Linux shared library export only a small number of functions and the application only uses one of those.
Specifically, the application calls a function:
signed short WINAPI MyWinFunc (unsigned short a, void *b, void *c, unsigned long *d, void *e, unsigned char f, char g, unsigned char *h); |
signed short MyLinuxFunc (unsigned short a, void *b, void *c, unsigned short *d, void *e, char g, unsigned char *h); |