Compiling Bochs on Mac os x Snow Leopard

2020-05-27 10:48发布

Was someone able to compile the Bochs simulator under Snow Leopard. Leopard worked fine for me but under Snow Leopard I get alot of problems related to the Carbon library...

Ok, some more information was request.

  • I compile with make on the shell; stanard build process coming with the bochs sources
  • I was successfully able to compile against the 10.5 SDK. Unfortunatley, it was not running under Snow Leopard... always crashed
  • then I installed the latest XCode from the SnowLeopard CD and compiled against the 10.6 SDK; withot changing nothing but the isysroot flag to point to the 10.6 instead of 10.5 now the compiler has problems to find some carbon headers... (-framework Carbon is included as a parameter to g++)

Here the error... it fails when it comes to compiling the carbon-based gui for bochs:

g++ -c  -I.. -I./.. -I../iodev -I./../iodev -I../instrument/stubs -I./../instrument/stubs -pipe -O3 -isysroot /Developer/SDKs/MacOSX10.6.sdk -framework Carbon -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  -fpascal-strings -fno-common -Wno-four-char-constants -Wno-unknown-pragmas -Dmacintosh -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES    carbon.cc -o carbon.o
carbon.cc:154: warning: non-local variable ‘<anonymous enum> last_screen_state’ uses anonymous type
carbon.cc:154: warning: non-local variable ‘<anonymous enum> screen_state’ uses anonymous type
carbon.cc:163: error: ‘CIconHandle’ does not name a type
carbon.cc: In function ‘OSStatus CEvtHandleWindowBackdropUpdate(OpaqueEventHandlerCallRef*, OpaqueEventRef*, void*)’:
carbon.cc:278: error: ‘GetWindowPortBounds’ was not declared in this scope
carbon.cc:279: error: ‘BackColor’ was not declared in this scope
carbon.cc:280: error: ‘EraseRect’ was not declared in this scope

... many more undeclared xxx errors

thanks in advance Mac

9条回答
Lonely孤独者°
2楼-- · 2020-05-27 11:26

Easiest way for mac is ....

brew install home/x11/bochs

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

查看更多
仙女界的扛把子
3楼-- · 2020-05-27 11:28

Brew makes it work so it can be used as a starter before customisations.

Following the steps from the bochs formula:

brew install pkg-config libtool sdl2

# Download and extract Bochs
curl -OL https://download.sourceforge.net/project/bochs/bochs/2.6.9/bochs-2.6.9.tar.gz
shasum -a 256 -c <<< 'ee5b677fd9b1b9f484b5aeb4614f43df21993088c0c0571187f93acb0866e98c  ./bochs-2.6.9.tar.gz'
tar xzf bochs-2.6.9.tar.gz
rm bochs-2.6.9.tar.gz
cd bochs-2.6.9

# Download and apply patch
curl -O https://raw.githubusercontent.com/Homebrew/formula-patches/e9b520dd4c/bochs/xcode9.patch
shasum -a 256 -c <<< '373c670083a3e96f4012cfe7356d8b3584e2f0d10196b4294d56670124f5e5e7  ./xcode9.patch'
git apply ./xcode9.patch
rm xcode9.patch

# Configure and install
./configure --disable-docbook \
  --enable-a20-pin \
  --enable-alignment-check \
  --enable-all-optimizations \
  --enable-avx \
  --enable-cdrom \
  --enable-clgd54xx \
  --enable-cpu-level=6 \
  --enable-debugger \
  --enable-debugger-gui \
  --enable-disasm \
  --enable-fpu \
  --enable-iodebug \
  --enable-large-ramfile \
  --enable-logging \
  --enable-long-phy-address \
  --enable-pci \
  --enable-plugins \
  --enable-readline \
  --enable-show-ips \
  --enable-smp \
  --enable-usb \
  --enable-vmx=2 \
  --enable-x86-64 \
  --with-nogui \
  --with-sdl2 \
  --with-term
make
make install

Now it should be installed (bochs --help), before running it don't forget to set the $BXSHARE environment variable.

查看更多
Root(大扎)
4楼-- · 2020-05-27 11:31

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

查看更多
神经病院院长
5楼-- · 2020-05-27 11:31

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
make
sudo make install
查看更多
老娘就宠你
6楼-- · 2020-05-27 11:39

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"
查看更多
霸刀☆藐视天下
7楼-- · 2020-05-27 11:39

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}
查看更多
登录 后发表回答