Winelib and C++ static initialization

Luke Dunstan lukedunstan81 at gmail.com
Wed Aug 26 18:53:22 CDT 2015


On Thu, 27 Aug 2015 at 00:44 Stefan Dösinger <stefandoesinger at gmail.com>
wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hi,
>
> You dropped the wine-devel CC. Was that intentional? There are people
> who have more clues about winelib than I do.
>
No, it was accidental, sorry.


>
> >> I found that OutputDebugStringA doesn't write anything here,
> >> even if successful. I replaced it with printf calls to get
> >> actual output.
> >
> > OK, but why exactly is this necessary? This is just an artificial
> > example to demonstrate the general problem.
> I looked into the source code of OutputDebugStringA, but I couldn't find
> an obvious answer. It certainly does a lot more than just write a string
> to STDOUT. I didn't really understand what it was doing.
>

Yes, it sends the message to the attached debugger if any, not to stdout.
On Windows or Wine you can run SysInternals DbgView.exe to see it. It's
just an example though, and many other APIs also crash when called from
initialisers.

>> Though it's not quite working here either:
> >
> > Any ideas why, or how it could be fixed?
> Sorry, no idea :-( .
>
> > Yes. My hope was that Winelib could be used to help port a legacy
> > Windows CE 4.x application to Linux (ARM, though I am testing on
> > x86 right now). Initially I could try compiling on Windows and
> > running it on Linux, but the real goal would be to port the
> > application in stages, so changing a few modules at a time to use
> > Linux APIs while leaving some parts using the Win32 (and MFC) APIs.
> > Eventually there would be no need for Winelib but I'd expect that
> > porting all of the code at once would resulting in a lot more
> > debugging effort because changes would not be localised.
> Hmm yeah, that sounds like a task where you need winelib. Unfortunately
> winelib isn't something that gets used a lot, and even less so with C++.
>
> Also keep in mind that Wine doesn't target Windows CE applications, so
> you'll have to invest a lot of time into bridging Windows CE <-> Win32
> differences.
>

Yes I understand, but fortunately most of the application also runs on
normal Win32.

You'll also have to compile MFC with Winelib to target ARM. It should
> be possible to compile MFC (or at least parts of it) with winelib, but
> I don't expect this to be easy either.
>

That's true, and that was actually the first thing I tried to do. I tried
both static and dynamic libraries but it crashes before it gets to
WinMain(), hence my question. GDB can trap the crash but the stack trace
gives no function names or other useful information.

(gdb) bt
#0  0x00000000 in ?? ()
#1  0x7ec4b7c0 in ?? ()
#2  0x7ec4b77e in ?? ()
#3  0x7ec4b79e in ?? ()
#4  0xb7febd77 in ?? ()
Backtrace stopped: previous frame inner to this frame (corrupt stack?)

Winedbg cannot even get that far. But I will try 1.7...

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


More information about the wine-devel mailing list