Hello winos, 

I'm trying to make a winelib program that makes use of a windows DLL.  I'm
having trouble understanding how to generate the stub/passthrough lib that is
supposed to wrap calls to the functions in the DLL.  The windows DLL is called
qtmlclient.dll.  I created a qtmlclient.spec file that looks like this:
        name      qtmlclient
        type      win32
        mode      dll
        995 cdecl InitializeQTML( long ) QTMLCLIENTDLL_InitializeQTML

My qtmlclient.c file looks like this:
        #include <windef.h>
        #include <assert.h>
        #include <Movies.h>     // has def of OSErr
        OSErr __cdecl QTMLCLIENTDLL_InitializeQTML(long flag) 
        { assert(0); return 0; }

I compile together qtmlclient.spec.o and qtmlclient.o to form libqtmlclient.so:
        gcc -shared -Wl,-soname,libqtmlclient.so,-rpath,/usr/local/lib
qtmlclient.spec.o qtmlclient.o -o libqtmlclient.so.1.0 -L../dlls -lkernel32
        rm -f libqtmlclient.so && ln -s libqtmlclient.so.1.0 libqtmlclient.so

My winelib app is called qtsample.  qtsample.spec looks like this:
        name    qtsample
        mode    guiexe
        type    win32
        init    WinMain
        import  qtmlclient.dll

I've put libqtclient.so* in the current directory, then I link it all together
like this:      
        gcc -o qtsample qtsample.o qtsample.spec.o -L../dlls -L. -lqtmlclient
-lgdi32 -lkernel32 -luser32 -L../dlls  -L.. -lwine -lwine_unicode -lncurses -lm
-lutil -ldl

However, I still get the following linker error:
        qtsample.o: In function `WinMain':
        /usr1/home/mogul/quicktime/test/qtsample.c:254: undefined reference to
`InitializeQTML'

If I look at the symbols I have this:
        > nm -o *o | grep InitializeQTML
        libqtmlclient.so:00028770 T QTMLCLIENTDLL_InitializeQTML
        qtmlclient.o:00000000 T QTMLCLIENTDLL_InitializeQTML
        qtmlclient.spec.o:         U QTMLCLIENTDLL_InitializeQTML
        qtsample.o:         U InitializeQTML

Plainly the QTMLCLIENTDLL_InitializeQTML is being compiled in, but what do I
have to do to satisfy the InitializeQTML reference and make sure that the
QTMLCLIENTDLL_ version gets called?  I am trying my damndest to interpret
documentation/HOWTO-winelib, but I get totally lost at this section:

 [...]
 In order for WineLib to use the Windows DLL, certain glue code is
 needed to replace the linker magic that windows compilers use. Part of
 the glue code must be written by you. The basic idea of the glue code
 is that you write a new DLL that consists of function pointers. Each
 function in the DLL will consist of a call on a function pointer. For
 example, 
     WINEDLL_ConstString WINEDLL_INTERFACE 
     WINEfullName( WINEDLL_ConstString handle ) {
         return (* pWINEfullName) ( handle );
     }
 The initialization function for the DLL will use the function
 LoadLibrary() to load the windows DLL and initialize the function
 pointers using the function GetProcAddress(). 
 [...]

(This whole section would be MUCH more clear if the author used a hypothetical
.DLL with some name "foo.dll" and a winelib app named "bar".  As it stands, the
WINE-ized names make this incredibly complex to understand despite it looking
like very little code.)

Can anyone clarify what's needed?  

(Incidentally, I'm well aware that Quicktime the application isn't working with
Wine... My goal was to write a winelib application that just calls the Quicktime
API to do decoding.  Hopefully this way I can get a Sorenson codec Quicktime
player under Linux... A worthy goal, so won't you help?  =)  )

Thanks in advance,

Bret

Reply via email to