[Mono-winforms-list] SWF & Winelib Q&A

Peter Dennis Bartok peter@novonyx.com
Fri, 19 Mar 2004 14:02:18 -0700


Hi All,

I figured since there are quite a few questions regarding winelib that 
I'd write a little blurb on how things are connected. I tried to start 
it in FAQ form to allow later inclusion into the FAQ.
Let me know if it helps, if you have additional questions or if you 
notice something wrong/missing.

1. What dependencies does System.Windows.Forms (SWF) have?
2. When running a SWF application I get the 
System.DllNotFoundException:winelib.exe.so exception. What's wrong?
3. How can I verify that I've got winelib installed correctly?
4. When trying to run a SWF application I get the 
System.DllNotFoundException:user32.dll exception. What's wrong?
5. When running a SWF application I don't get the usual nice exception 
with stack and everything. What happened?
6. How does winelib work?
7. Why do I have to do those links from wine to the lib directory?


1. What dependencies does System.Windows.Forms (SWF) have?
The following is the dependency tree:
-> System.Windows.Forms
    -> Winelib
       -> Wine
    -> System.Drawing
       -> gdiplus
          -> cairo
             -> pixman
             -> freetype
             -> Xrender

Unless you have *all* of these libraries working on your system, SWF 
will not operate (and in most cases even initialize).


2. When running a SWF application I get the 
System.DllNotFoundException:winelib.exe.so exception. What's wrong?
Several possible causes:
- The winelib package is not installed
- Winelib is installed but wine is not
- winelib.exe.so is not in <prefix>/lib


3. How can I verify that I've got winelib installed correctly?
Winelib will be installed into the <prefix>/lib directory. <prefix> was 
chosen when the install packages was created. If you want to have 
winelib in another directory than the default where it was installed to, 
you must get the source packages and configure & compile it for a 
different path.


4. When trying to run a SWF application I get the 
System.DllNotFoundException:user32.dll exception. What's wrong?

In order for SWF and winelib to operate properly you need to have 
symbolic links for the wine dlls in the <prefix>/lib directory. While 
the rpm should install those automatically as part of the postinstall 
script you can also manually create those with the following command:

cd <prefix>/lib
for i in <wine_dll_dir>/*dll.so; do ln -s $i lib`basename $i`; done

<prefix> is the base directory where mono is installed under (ie. /usr 
or /usr/local) and <wine_dll_dir> is the directory where the wine dlls 
(user32.dll.so, gdi32.dll.so, etc) can be found (ie. /usr/lib/wine or 
/usr/local/lib/wine)

5. When running a SWF application I don't get the usual nice exception 
with stack and everything. What happened?
This is a known issue, when initializing wine the mono exception handler 
is replaced with the wine exception handler. This will be fixed shortly.


6. How does winelib work?

Winelib performs the same wine initialization as the command-line 'wine' 
application. As 'argument' it uses itself, effectively telling wine to 
rune winelib.exe.so. Before initializing, wine does a setjmp and when 
wine calls the winelib.exe.so WinMain function we perform a longjmp
back to right after the wine initialization code was called. This 
results in wine being initialized and control being back at the routine 
that got called from SWF.


7. Why do I have to do those links from wine to the lib directory?

Currently mono is not using the LD_LIBRARY_PATH to find libraries, and 
also, mono has a particular naming format it expects libraries to have, 
all libraries have to start with 'lib', and the wine dlls don't conform. 
The symbolic links remedy this issue.