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

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


> 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 as:
and place a soft link to it as

Don't forget to install the .def file as:

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

wineg++ -mwindows -o <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,

"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

Do you Yahoo!?
New and Improved Yahoo! Mail - Send 10MB messages! 

More information about the wine-devel mailing list