Bochs Emulator – Config & Build on Windows and OS X


Bochs is an x86 – x86-64 multiplatform emulator that provides emulation of CPU Instruction Fetching without using Hypervisor technologies like Intel’s VT-x and AMD-V. One of the benefits of emulation rather than virtualization is that you can execute instructions of old discontinued CPU structures in modern CPU or run Intel’s instructions on an AMD CPU or vice versa, more than that Bochs developers try to make Bochs devices like virtualization software devices.They provide keyboard, speaker, cdrom, disk, floppy, network device and etc. Emulation is somehow like high-level programming languages like Java when using its bytecode or .Net Framework when using MSIL. From IBM :

Java technology implements just-in-time (JIT) compilation to work around some of the inefficiencies, similar to Transmeta and numerous other emulation solutions (including QEMU, another platform emulation solution similar to Bochs). But Bochs also achieves efficient emulation (up to 100 million instructions per second [MIPS] on a modern processor) while also being portable. Bochs was developed purely in the C++ language for interpreted x86 instruction execution and platform emulation.

Bochs   Because of instructions doesn’t directly execute on a Bochs machine, It is too much slower than CPU on virtualization so Bochs comes at the cost of performance. Even though Bochs is really slow but it gives us other benefits that worths using the emulator like Instrumenting an operating system kernel which I described in Bochs Emulator – Debug & Instrument. Bochs is an open-source program and in order to use some features like instrumentation and other optimization you need to compile it by your self, more than that you can edit the source code for researching because Bochs have lots of cool features that can be manipulated in order to better optimize your needs, so I prefer to compile it rather than downloading its binaries. ok, that’s enough for introduction, let’s see how to “make” it! In the rest of topic, I’m trying to build bochs-2.9.

Configure & Make in OS X

First, you need to download the project source code, you can find it here. The documentation uses the following syntax in order to build the Bochs on OS X machines

But it gives me the following error after running “make”:

that’s a weird error! I don’t know why this happens but I simply go to “” file and change the following line:


And simply ignore this problem. Let’s “make” it again.

That’s too bad! 20 errors. I googled it and understand that this problem happens because the libraries that it used for it’s GUI is no longer available for OS X, so the problem can be solved using SDL instead. Now you need to download and install SDL.

Then compile the Bochs using the following syntax.

Even though this problem is reported to Bochs developers but it seems none of them uses OS X, I’m sure this problem will be solved in the future versions of Bochs. Finally, it compiles without error, but actually, I want to use more features of Bochs like disasm and debug features and instrumentation and etc. I use the following syntax to compile the Bochs:

If there isn’t any problem, you can now run the Bochs. This time, when I run Bochs it gives me the following error:

Actually, this problem happens because the CPU architecture that selected in “.bochsrc” file is not available in the current built. You should run the following command in order to get the supported CPUs:

Then I modified the following line:

change the “core2_penryn_t9600” to e.g “core_duo_t2400_yonah”. Running bochs again produces such error :

It is because we didn’t configure Bochs for preparing sound device and we use “sound” option in “.bochsrc”, in order to build with sound support you can use one of the “–enable-sb16” or “–enable-es1370” in configuring and “make” again but I rather remove the following line from “.bochsrc” to build it again.

Now it runs without error.

Building Bochs on Windows

To build Bochs for Windows you have multiple options, like building with Cygwin or MinGW but I’d rather build Bochs with Visual Studio instead. Download ( latest version from here. Extract the go to vs2013 and open “bochs.sln”. You need to enable some of the features before building the solution. (It’s like ./configure –enable-x in OS X and Linux) Go to “config.h” and modify it like this: In order to enable debugging make sure your config file is :

I also need Instrumentation so changed the following line:

make sure disable BX_SUPPORT_HANDLERS_CHAINING_SPEEDUPS because of some incompatibility issues.

Then trying to build and this time it gives me the following error:

And other such errors which are linking problems. I add the following line to :

That line solves the linking problems. If there isn’t any error then just build the solution.

Installing Windows on Bochs

Installing an operating system in Bochs is a little tricky, open bochs.exe (from what you built before.) then make sure that it starts without any problem (some systems have problem opening Bochs !). Bochs uses an image file for the purpose of its hard disk, there is a tool called bximage.exe which creates such file for you. Open bximage.exe :

Then choose 1 (Create new floppy or hard disk image). In the second step choose hd for device type, growing for the next question and then choose how much space you need to allocate to your emulated machine. In the last step specify a name and you’re good to go! A complete result of bximage is like :

After creating the image file, now you need to configure your Bochs machine. Open the Bochs.exe and edit the memory option. Set the memory size (megabytes) and host allocated size (megabytes) to a value greater than 32!  I choose 1000. Then edit CPU option > CPU Configuration to turion64_tyler or whatever supports x86-64, make sure to set a proper value for Emulated instructions per second (IPS). Press OK and edit Disk & Boot > ATA Channel > First HD/CD on channel 0. In this window set Type of ATA device to disk, set path or physical device name to the c.img (the file that is created previously by bximage), Type of disk image to growing, Cylinders to 20317, heads to 16, Sectors per track to 63. Now go to another tab (Second HD/CD on channel 0) and set the type of disk to cdrom, Path or physical device name to the Windows ISO file. For the last step go to Boot Options, set Boot drive #1 to disk and Boot drive #2 to cdrom. That’s it, make sure to save your configuration to avoid doing these steps again and then press start. Select continue and don’t ask again if a prompt comes to the screen then restart the machine and you should see the Windows installation. If you see the following picture, then you’re done. final-bochs By now, you should’ve configured Bochs, Let’s use more features of Bochs in the next post. (Bochs Emulator – Debug & Instrument).

This post is written in cooperation with my friend sima.


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.