#1342 Problem when Compiling under MSVC 2012


There are several issues when I was trying to compile bochs under MSVC 2012.

Source: SVN 11891
Platform: Windows 8 Pro 64
Build System: MinGW/MSYS (for running configuration script), Microsoft Visual Studio 2012 x64 Native Tools (for actual compilation). Compile using the NMAKE method.

1: MSVC standard library becomes angry when it detects some C++ keyword was overwritten. This happened because the auto generated config.h has a #define inline __forceinline directive that maps "inline" to a compiler-specific keyword so plain C file can use it. But when Compiling under C++ mode, the standard library issued an #error.
xkeycheck.h(242): fatal error C1189: #error : The C++ Standard Library forbids macroizing keywords. Enable warning C4005 to find the forbidden macro.
As a workaround, surrounding this #define with a #ifndef __cplusplus block can help.

2: When compiling bximage_new.cc, compile error occurred because <winioctl.h> was directly included but some win32 types such as BYTE, DWORD are not defined. I can't figure out what headers are exactly necessary, so I just tried #include <windows.h> and it seems work.

3: Plugin system doesn't work. When plugins are enabled, bochs will PANIC because it cannot load necessary module. Those module are in fact not build.

There is one more problem that makes bochs crash when simulation starts, but I just caught it randomly with release build. When I tried to build a debug version and figure out where this crash come from, I got no luck. (sigh)


  • Volker Ruppert

    Volker Ruppert - 2013-10-17

    The items #1 and #2 are fixed now in SVN revision 11893. Item #3 is a known issue and reported in our user doc. MSVC nmake doesn't understand the syntax used in our makefiles for building plugins. That's why it builds the EXE, but no DLLs. The VS2008Ex gui can build a usable plugin system with the plugin specific workspace. Currently there is no search path supported, so the DLLs must be present in the same folder as the EXE.

  • Tippisum

    Tippisum - 2013-10-18

    With some more test on building, I find something interesting.
    The configure script does recognize cl.exe as an available C++ compiler, so the configuration step run "near native" under Windows (one still needs a POSIX compatible shell so that "./configure" can actually run)
    This can be achieved by starting a MSYS shell under the Visual Studio Developer Command Prompt (which sets up all environment variables suitable for invoking MSVC toolchain), and without mounting MinGW. I haven't tried cygwin, but I think things should be similar.
    And the configuration script does have different behavior compare to running under a fake environment where it saw gcc as the compiler. Most noticeably change is that it will now substitute "inline" with "__inline" instead of "__forceinline", which I think is more precise behavior, and the library won't complain to this. the #2 problem is also vanished due to some unknown reason.
    Though I'm not sure, I guess the autoconf guys indeed have put some effort working with the MSVC toolchain. So maybe we can build bochs under Windows using the nearly same configuration method, without a whole "configure - pack - compile" burden, and it may even be less error-prone. I have successfully build bochs this way, and everything seems fine.

    However, there are some subtle issues with the "make" of MSYS, so I need to use "nmake" instead of the normal "make". You point out that nmake don't understand the syntax used in makefiles, so I made some attempt to use the MSYS "make" to do the work, but it don't work. One problem comes up from the MSYS naming convention, which treats the cl commandline switches starting with "/" as POSIX paths, and then substitutes them with something strange. There are more problems like make says it cannot find the making rule for some target, while it is obviously right there in the makefile (and nmake can recognize it). I can't figure out all these problems, so maybe the "make" tool is still incompatible with MSVC build. But I still think it would be really nice if Win32 builds can use the same "configure - make" step just like other platform :)

    BTW, is building under MinGW toolchain supported? I found there are MinGW configurations in the script and I managed to get a working build, but the user doc didn't mention anything about MinGW build. Is it fully supported, or just some experimental feature?

  • Volker Ruppert

    Volker Ruppert - 2014-05-24

    Item #3 (building plugins) is now supported in SVN , but still experimental.

  • Volker Ruppert

    Volker Ruppert - 2014-05-24
    • status: open --> closed
    • Group: can't_reproduce --> fixed_in_SVN

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.

No, thanks