Compiling Bochs on Mac os x Snow Leopard

若如初见. 提交于 2019-12-03 03:03:00

I was finally able to accomplish this myself, but it took a little more work than I expected. Bochs can be a little temperamental to install, even on Linux.

Note

Forget about attempting to compile with Carbon. Apple is deprecating it and you won't be able to compile applications in 64-bit with it (the default for Mac OS X). http://appleinsider.com/articles/12/02/18/mountain_lion_focuses_on_cocoa_drops_x11_and_deprecates_carbon

BTW, the Bochs team doesn't use Mac OS X and probably won't be fixing this issue. This could be your chance to help an open source project: http://sourceforge.net/p/bochs/bugs/1204/

That said, you should be able to compile with SDL support with a little tweaking.

Install the SDL 1.2 Library

I could never get the SDL library from http://www.libsdl.org to work correctly, so I used Homebrew -- http://brew.sh -- to install it:

brew install sdl

Configure Bochs

I like to configure Bochs with the debugger (for OS development) and I like to install it into my home directory (in case I want to delete it). Here is the configure command I use:

./configure --enable-ne2000 \
            --enable-all-optimizations \
            --enable-cpu-level=6 \
            --enable-x86-64 \
            --enable-vmx=2 \
            --enable-pci \
            --enable-usb \
            --enable-usb-ohci \
            --enable-e1000 \
            --enable-debugger \
            --enable-disasm \
            --disable-debugger-gui \
            --with-sdl \
            --prefix=$HOME/opt/bochs

Please note that I added --disable-debugger-gui because it is enabled by default if you choose to enable the debugger. However, since the debugger GUI relies on GTK+, and that isn't installed by default on Mac OS X, you want to disable it (GTK+ is another can of worms you don't want to deal with).

Building and Installing Bochs

Next, build and install

make
make install

Finally, just set your BXSHARE environment variable and update your path:

export BXSHARE="$HOME/opt/bochs/share/bochs"
export PATH="$PATH:$HOME/opt/bochs/bin"
Elias Bachaalany

In addition to James said (adding the -m32 switch), you may need to add "-arch i386" too.

Here's a modified conf file that I used to build:

set echo
CFLAGS="-arch i386 -m32 -pipe -O3 -I/sw/include -fomit-frame-pointer -finline-functions -falign-loops=16 -falign-jumps=16 -falign-functions=16 -falign-labels=16 -falign-loops-max-skip=15 -falign-jumps-max-skip=15 -fprefetch-loop-arrays $CFLAGS"
CPATH="/sw/include"
CPPFLAGS=""
CXXFLAGS="$CFLAGS"
LDFLAGS="-arch i386 -m32 -L/sw/lib"
CXX="g++ -arch i386 -m32"

export CFLAGS
export CPATH
export CPPFLAGS
export CXXFLAGS
export LDFLAGS
export CXX

./configure --enable-sb16 \
     --enable-ne2000 \
     --enable-all-optimizations \
            --enable-cpu-level=6 \
            --enable-x86-64 \
            --enable-sse=2 \
            --enable-pci \
            --enable-acpi \
            --enable-debugger \
            --enable-clgd54xx \
            --enable-usb \
     --enable-plugins \
     ${CONFIGURE_ARGS}

First, you'll have to run "make dist-clean" to get rid of some of the library code which will have compiled successfully in 64-bit mode - this isn't deleted by a regular "make clean", only the more radical dist-clean. Otherwise, your build will try to mix 32 and 64 bit code, which doesn't work.

Now set CFLAGS and CXXFLAGS to contain the -m32 switch to force 32 bit mode. Re-run ./configure, then make, and you should get a working 'bochs' binary.

Having got past the build problems, though, you'll probably find the Carbon version no longer runs; the X11 version seems to be a better bet. (At least, on my Snow Leopard system, the Carbon build fails early with an assertion failure; X11 works as expected.) You may be able to get a 64 bit X11 build running, without the Carbon dependency, but I haven't tried this yet, only 32 bit.

Snow Leopard compiles 64-bit by default, but GUI Carbon apps have to be 32-bit.

ekscrypto

If you want to run Bochs on a 64-bit Mac, you will need to use a different GUI library. I recommend using X or SDL.

SDL: To do so, first download and install the LibSDL from http://www.libsdl.org/download-1.2.php, you will need the binaries and development libraries.

After extracting the Bochs source files, run ./configure --with-sdl=path-to-libsdl-dev-files.

X11: It should build out of the box: ./configure --with-x11 && make

Todd Wilsson

@user6779

Make sure you do not use the flat unix binary that is created, but rather the Mac OS bundle (called bochs.app).

Eg from the terminal:

./bochs.app/Contents/MacOS/bochs

And you will no longer receive that assertation.

This how it worked for me under MacOS X 10.10 with Xcode7 developer tools and XQuarz 2.7.7

export CFLAGS=-I/opt/X11/include
export CXXFLAGS=-I/opt/X11/include
export LDFLAGS=-L/opt/X11/lib -lX11
./configure   --enable-debugger --enable-debugger-gui   --enable-all-optimizations    --enable-x86-debugger   --enable-ne2000   --enable-e1000  --enable-pnic   --with-x11  --without-carbon`enter code here`
make
sudo make install

Easiest way for mac is ....

brew install home/x11/bochs

I Tried other way for long times..And Failed.. Under MacOS X 10.11

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!