Wine on Windows

Building wine with mingw on Windows

The wine wiki says wine builds somewhat with mingw, so I gave it a shot on a windows 7 box:
  1. mingw has a nice installer now; I installed the 'mingw developer toolkit' (i.e. downloaded and ran the latest installer from and checked 'mingw developer toolkit' )
  2. in cmd, did
    to create msys user directory
  3. Got a wine source tree (e.g. by doing
      cd /cygdrive/c/mingw/msys/1.0/home/$USERNAME
      git clone git:// wine-git
    in a cygwin window.)
  4. In the msys window started in #2, did
      cd wine-git
      ./configure --without-x --without-freetype
"make depend" alone takes fifteen minutes.

If make fails early with an odd error about mode_t already being defined, you may have interrupted configure so that it didn't generate a proper include/config.h. You can recover by running

   config.status include/config.h
If make fails with "libd3dcompiler.a: no such file or directory", you may have hit bug 29569, try inserting the missing dll/ in four lines in Makefile, e.g.
sed -i 's,$(LN_S) ,$(LN_S)/dlls' Makefile

Building Wine with Visual Studio 2005 on Windows

The wine wiki says wine builds somewhat with Visual Studio, so I gave it a try on a windows 7 box. Here's a recipe that kind of works:
  1. Configure wine using mingw as described above
  2. Build tools/winebuilder with mingw (i.e. in an msys window, do "cd tools/winebuilder; make") then create tools/winebuilder/Output/Win32_Debug and copy winebuild.exe there. This is only needed because msvcmaker doesn't generate a project for winebuild yet.
  3. Verify that include/config.h is more than 81 lines long (it should be about 1300 lines long). If it's short, run
    config.status include/config.h
    in an msys window to regenerate it.
  4. Work around the lack of unistd.h in visual C++ by creating include/unistd.h that just has the two lines
    #include <io.h>
    typedef int ssize_t;
    since mingw puts read() and write() in unistd.h, but visual c++ puts them in io.h. (The right way to fix this might be to make the unistd.h includes conditional on HAVE_UNISTD_H, but then I don't know where ssize_t would come from.)
  5. Run tools/winapi/msvcmaker to generate the .dsp and .dsw files. You may need to apply the patch from to get this to not complain about uninitialized variables. Make sure you're not in Visual Studio when you do this, or the files might not get updated.
  6. In a CMD window, make sure midl.exe is on the PATH, then start Visual Studio 200x.
  7. In Visual Studio 200x, load wine.dsw. The IDE will convert all .dsw/.dsp files to .sln/.vcproj files. The .dsw and .dsp files are then no longer used. (Always do this when starting the IDE. If you try to reuse the .sln/.vcproj files on the next IDE session, it barfs and says there is an invalid XML character, at least with Visual Studio 2005 Express.)
  8. Right click on one of the subprojects and build it. The first couple build ok, but advapi32 and rpcrt4 fail to build.
Even though Visual Studio doesn't successfully build wine, it's close enough to let the PVS-Studio static analyzer try to analyze wine's source code.