How to deal with C++ APIs in wine spec file

Jon Griffiths jon_p_griffiths at yahoo.com
Fri Oct 1 09:48:36 CDT 2004


Hi,

> how can I call a class constructor (which is built form
> another class) in spec file? Can anyone provide me an example? 

This is possible, although it is not immediately obvious. Here is the
solution I use (I will document this one day but I'm very busy ATM):

Scenario 1: App uses C++ dll, dll does not use win32 calls

Solution: Compile as non wine dll (unix .so) and link.

Scenario 2: App uses C++ dll, dll uses win32 calls

Solution 1: Static link with the object files of the dll. Winebuild
will resolve references to win32 calls.

Solution 2: Use native .exe and dlls

Solution 3: Compile as wine dll with one extern "C" dummy function
that does nothing. Do _not_ attempt to export any C++ symbols.
install the resulting .dll.so as:
/usr/local/lib/wine/NAME.dll.so
and place a soft link to it as
/usr/local/lib/libNAME.dll.so

Don't forget to install the .def file as:
/usr/local/lib/wine/libNAME.def

Link as a wine dll _and_ a unix .so. e.g:

wineg++ -mwindows -o app.exe.so <opts> -lNAME -lNAME.dll

In any dll or program that calls functions from the dll, place a call
to your dummy function immediately after WinMain(). This will force
winebuild to link to the dll and the loader to set up the Win32
function pointers in the dll. Due to dlopen magic the ctors/dtors for
statics will only be called once.

Be carefull with the order of static object initialisation, you may
need to use gcc's attribute init_priority to ensure correct ordering,
or defer static initialisation until after loading

Hope this helps,
Jon


=====
"Don't wait for the seas to part, or messiahs to come;
 Don't you sit around and waste this chance..." - Live

jon_p_griffiths at yahoo.com


		
__________________________________
Do you Yahoo!?
New and Improved Yahoo! Mail - Send 10MB messages!
http://promotions.yahoo.com/new_mail 



More information about the wine-devel mailing list