Winelib and C++ static initialization

Luke Dunstan lukedunstan81 at gmail.com
Wed Aug 26 09:33:47 CDT 2015


Hi,

I am new to Winelib and I have crashes with very basic C++ code. Consider
the following code:


#include <windows.h>

struct MyInit {
        MyInit() {
OutputDebugStringA("Init ctor\n");
}
};
MyInit InitObj;

extern "C" int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE
hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
OutputDebugStringA("WinMain()\n");
return 0;
}


If I compile it on Ubuntu 32-bit with wine-1.6.2 with:

wineg++ -c -mno-cygwin -o hello.o hello.cpp
wineg++ -mwindows -mno-cygwin -o hellocpp.exe hello.o

The result is:

$ ./hellocpp.exe
Segmentation fault (core dumped)

On Windows this program obviously outputs "Init ctor\n" followed by
"WinMain()\n", as viewed in DbgView. Removing the call to
OutputDebugStringA from the static constructor prevents the crash in
Winelib.

How do I get C++ static initialization to work properly in Winelib?

Thanks,
Luke
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.winehq.org/pipermail/wine-devel/attachments/20150826/7afc7e06/attachment.html>


More information about the wine-devel mailing list