Linking wine *dll.so libraries with Linux applications ?!
wine at troy.rollo.name
Thu Oct 20 15:49:18 CDT 2005
On Thursday 20 October 2005 22:45, Alexander Efremov wrote:
> architecture is somethink like
> |Linux Executable| --uses--> |Linux *.a and *.so libraries| +
> + |my Linux *.so library| --uses--> |Other Linux *.a and *.so
> libraries + WineLib avifil32.dll.so|
OK, then you will need to use the longjmp method.
> By the way what exactly causes the segmentation fault during the
> execution ?
Something (and it could be one of many things) that is not initialised when
you call the library.
> A also tried to compile and link WineLib *.dll.so applications using
> normal g++ for compilation and linking - just ignoring all the
> resource files - and it worked... but at the end i got the same
> segmantation fault :-(
That is what I would expect. You can't just use normal g++ - winegcc is doing
a lot of magic stuff for Wine.
It looks like you are going to have to use the longjmp method. Create a
WineLib application whose WinMain just jumps back to some other routine. It
will probably be worth patching winegcc and the Wine launcher code so that
winegcc marks the executable at 3Gig-aware (based on a flag to winegcc) and
the Wine launcher code recognises the flag and avoids reserving the 2-3G part
of the address space. This should be enough that you can avoid mucking about
with stacks and unmapping stuff wine has mapped.
You should have an arrangement that looks something like this:
1. Your DLL that wants to call the Win32 API links to a "startwinelib.so"
with an entry point "start_wine_lib_for_dll".
2. "startwinelib.so" is a winelib app. "start_wine_lib_for_dll" would contain
a "setjmp" followed by a call to wine_init, passing a dummied up argv
that tells wine to start "startwinelib.so".
3. WinMain in "startwinelib.so" does a longjmp back to
4. From this point on you should be able to call the Win32 API as much as
you like, even from files compiled with plain old gcc or g++.
5. You may need to set up an exception frame that does something like
calling "exit" after printing a message about there being an
More information about the wine-devel