準備工作:
首先,安裝以下軟體:
sudo apt-get bulid-essional (如果以前安裝過就免了)
sudo apt-get install xorg-dev
sudo apt-get install bison
安裝bochs:
然後到bochs官方網站下載下傳源碼包 bochs-2.4.2.tar.gz
解壓此檔案:tar vxzf bochs-2.4.2.tar.gz
cd bochs-2.4.2
./configure --enable-debugger --enable-disasm
make
sudo make install
注意:在以上過程中可能會遇到錯誤,不必驚慌,到百度上去找答案吧,而且每次在執行
sudo apt-get install 這條指令時應該退出終端,然後再從頭開始一步一步來。
配置bochs:
安裝好bochs之後,我們需要對bochs進行配置,其實就是對檔案bochrsc進行修改!
《orange's :一個作業系統的實作》的附帶CD光牒裡有一個已經配置好的bochrsc,但
是它是針對bochs2.3版本的,是以不能用!!!我們需要重新修改bochrsc!
首先将附帶CD光牒裡的chapter1子目錄下的檔案夾a 移動到/home/roothoo/,(主要是為
是讓a.img 和 bochsrc在同一檔案夾下,其次,這個檔案夾如果沒有,可以自己建立個文
件夾),然後對bochrc進行修改如下:
注意,#是注釋符号!即#之後的語句是無效的,其實#就相當于C+語言中的//
###############################################################
# Configuration file for Bochs
###############################################################
# how much memory the emulated machine will have
megs: 32
# filename of ROM images
#romimage: file=/usr/local/share/bochs/BIOS-bochs-latest
romimage: file=$BXSHARE/BIOS-bochs-latest
#vgaromimage: /usr/local/share/vgabios/vgabios.bin
vgaromimage: file=$BXSHARE/VGABIOS-lgpl-latest
# what disk images will be used
floppya: 1_44=a.img, status=inserted
# choose the boot disk.
boot: floppy
# where do we send log messages?
# log: bochsout.txt
# disable the mouse
mouse: enabled=0
# enable key mapping, using US layout as default.
keyboard_mapping: enabled=1, map=/usr/local/share/bochs/keymaps/x11-pc-us.map
注意看字型為紅色的那兩句!
修改好之後,别忘了儲存!
最後,我們運作bochs
cd /home/roothoo/a #我們切換到a.img 和 bochsrc所在的檔案夾,
bochs -f bochsrc #以bochsrc為配置檔案啟動bochs
然後選擇6,
然後再按c鍵,
OK!!!
ENJOY! -_-
其中針對可能出現的一些問題,列出了以下解決方案:
問題1:
checking for C compiler default output file name… configure: error: C compiler cannot create executables
解決辦法:
[[email protected] bochs-2.4]$ sudo apt-get install libc6-dev
問題2:
...
checking how to run the C++ preprocessor... /lib/cpp
configure: error: C++ preprocessor "/lib/cpp" fails sanity check
See `config.log' for more details.
解決方法:
[[email protected] bochs-2.4]$ sudo apt-get install build-essential
問題3:
[[email protected] bochs-2.4]$ make
make: *** 沒有指明目标并且找不到 makefile.停止。
解決方法:
[[email protected] bochs-2.4]$ sudo apt-get install build-essential
問題4:
...
checking for wxWidgets library version...
checking for default gui on this platform... x11
ERROR: X windows gui was selected, but X windows libraries were not found.
解決方法: 配置的時候加上"--with-nogui "
或者改成:[[email protected] bochs-2.4]$sudo apt-get install xorg-dev (建議)
問題5:
Package gtk+-2.0 was not found in the pkg-config search path.Perhaps you should add the directory
containing `gtk+-2.0.pc'to the PKG_CONFIG_PATH environment variableNo package 'gtk+-2.0' foundERROR:
pkg-config was not found, or unable to access the gtk+-2.0 package.Install pkg-config and the
gtk+ development package,or disable the gui debugger, or the wxWidgets display library (whichever is
being used).
解決方法:
[[email protected] bochs-2.4]$sudo apt-get install libgtk2.0-dev
問題6:
install: 無法擷取"./bochsdbg" 的檔案狀态(stat): 沒有該檔案或目錄
解決辦法:需要在make後,将bochs拷貝一份,命名為bochsdbg
[[email protected] bochs-2.4]$ cp bochs bochsdbg