CentOS8如何安装bochs2.6.11(上)

1:下载压缩包

bochs2.6.11https://sourceforge.net/projects/bochs/files/bochs/2.6.11
在这里插入图片描述

2:解压压缩包

tar -xvzf bochs-2.6.11.tar.gz bochs-2.6.11/

3:开始安装

以下命令可以根据自己需求进行更改

./configure --prefix=/your_path/ --enable-debugger --enable-disasm --enable-iodebug --enable-x86-debugger --with-x --with-x11 

因为我是第一次安装CentOS,之前所有的环境均未配置过,所以输入以上命令会开始报各种错误,以下我列出几个自己遇到的问题,仅供参考:

问题1:

configure: error: in `/home/kaiwen.denge/Downloads/bochs-2.6.11':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details

问题分析:
缺少C语言编辑器
解决方案:
sudo yun install gcc

问题2:

configure: error: in `/home/kaiwen.denge/Downloads/bochs-2.6.11':
configure: error: C++ preprocessor "/lib/cpp" fails sanity check
See `config.log' for more details

解决方案:
sudo yum install glibc-headers
sudo yum install gcc-c++

configure之后会生成Makefile,可以开始编译了

make install

不出意外的又报错了

问题3:

[kaiwen.denge@kaiwen bochs-2.6.11]$ make install
bash: make: command not found...
Failed to search for file: While loading repository failed to use /var/cache/PackageKit/8/hawkey/baseos.solv: repo_add_solv() has failed.

问题分析:
缺少make命令
解决方案:
sudo yum install make

问题4:

x.cc:37:10: fatal error: X11/Xlib.h: No such file or directory
 #include <X11/Xlib.h>
          ^~~~~~~~~~~~
compilation terminated.
make[1]: *** [Makefile:114: x.o] Error 1
make[1]: Leaving directory '/home/kaiwen.denge/Downloads/bochs-2.6.11/gui'
make: *** [Makefile:360: gui/libgui.a] Error 2

解决方案:
sudo yum install libX11-devel.x86_64

问题5:

/usr/bin/ld: gui/libgui.a(gtk_enh_dbg_osdep.o): undefined reference to symbol 'pthread_create@@GLIBC_2.2.5'
//lib/x86_64-linux-gnu/libpthread.so.0: error adding symbols: DSO missing from command line

问题分析:
pthread库不是Linux系统默认的库,链接时需要添加-pthread参数。
解决方案:
vi Makefile

92LIBS =  -lm -lgtk-x11-2.0 -lgdk-x11-2.0 -lpangocairo-1.0 -latk-1.0 -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lpangoft2-1.0 -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lfontconfig -lfreetype

在这行的末尾添加-pthread参数

注:如果make install后出现了很多以下这样的报错,直接重新再输入一遍以上configure命令即可。因为我们一开始配置时并没有这么多依赖,解决完上述问题过后重新configure就可以添加缺少的依赖。

/home/kaiwen.denge/Downloads/bochs-2.6.11/gui/x.cc:402: undefined reference to `XSetForeground'
/home/kaiwen.denge/Downloads/bochs-2.6.11/gui/x.cc:405: undefined reference to `XFillRectangle'
/home/kaiwen.denge/Downloads/bochs-2.6.11/gui/x.cc:406: undefined reference to `XSetForeground'
/home/kaiwen.denge/Downloads/bochs-2.6.11/gui/x.cc:411: undefined reference to `XDrawString'

继续make install

for i in /home/kaiwen.denge/bochs/share/doc/bochs; do mkdir -p $i && test -d $i && test -w $i; done
for i in CHANGES COPYING LICENSE README TODO misc/slirp.conf; do if test -f $i; then install -m 644 $i /home/kaiwen.denge/bochs/share/doc/bochs; else install -m 644 ./$i /home/kaiwen.denge/bochs/share/doc/bochs; fi; done
rm -f /home/kaiwen.denge/bochs/share/doc/bochs/README
cat ./build/linux/README.linux-binary ./README > /home/kaiwen.denge/bochs/share/doc/bochs/README
install -m 644 ./.bochsrc /home/kaiwen.denge/bochs/share/doc/bochs/bochsrc-sample.txt

终于算是成功了!!!!在我们之前安装的/your_path/目录中也有了

[kaiwen.denge@kaiwen bochs]$ ls
bin  share

4:运行bochs2.6.11

安装完成后,就应该配置bochs了,具体的配置方法可以参考share/doc/bochs/bochsrc-sample.txt中有关于启动配置的需求自己添加,以下我列出了我的配置文件,仅供参考。

# 第一步,首先设置Bochs 在运行过程中能够使用的内存,本例为 32MB
# 关键字:megs
megs: 32

# 第二步,设置对应真实机器的 BIOSVGA BIOS
# 对应两个关键字:romimage和vgaromimage
romimage: file=/home/kaiwen.denge/bochs/share/bochs/BIOS-bochs-latest
vgaromimage: file=/home/kaiwen.denge/bochs/share/bochs/VGABIOS-lgpl-latest

# 第三步,设置 Bochs 使用的磁盘,软盘的关键字为floppy.
# 若只有一个软盘,则使用floppya即可,若有多个,则为floppya,floppyb。。。。。。
# floppya: 1_44=a.img, status=inserted

# 第四步,选择启动盘符
# boot:floppy #默认从软盘启动,将其注释掉
boot: disk # 修改为从硬盘启动。

# 第五步,设置日志文件的输出
log: bochs.out

# 第六步,开机或关闭某些功能
# 关闭鼠标,打开键盘
mouse: enabled=0
keyboard: keymap=/home/kaiwen.denge/bochs/share/bochs/keymaps/x11-pc-us.map
#下面两行注释因为参照书中所写会报错:
#>>PANIC<< bochsrc.disk:24: 'keyboard_mapping' is deprecated - use 'keyboard' option instead
#所以我参照了bochsrc-sample.txt文件中有关于键盘的定义
#keyboard_mapping: enabled=1,
#keymap=/home/kaiwen.denge/bochs/share/bochs/keymaps/x12-pc-us.map 
# 硬盘设置
ata0: enabled=1, ioaddr1=0x1f0, ioaddr2=0x3f0, irq=1 

这下我们可以开始运行bochs了,直接在bochs安装路径下输入 bin/bochs

[kaiwen.denge@kaiwen bochs]$ bin/bochs 
========================================================================
                       Bochs x86 Emulator 2.6.11
              Built from SVN snapshot on January 5, 2020
                Timestamp: Sun Jan  5 08:36:00 CET 2020
========================================================================
00000000000i[      ] BXSHARE not set. using compile time default '/home/kaiwen.denge/bochs/share/bochs'
------------------------------
Bochs Configuration: Main Menu
------------------------------

This is the Bochs Configuration Interface, where you can describe the
machine that you want to simulate.  Bochs has already searched for a
configuration file (typically called bochsrc.txt) and loaded it if it
could be found.  When you are satisfied with the configuration, go
ahead and start the simulation.

You can also start bochs with the -q option to skip these menus.

1. Restore factory default configuration
2. Read options from...
3. Edit options
4. Save options to...
5. Restore the Bochs state from...
6. Begin simulation
7. Quit now

Please choose one: [2] 

按照bochs默认选项【2】继续回车,接下来会提示你选择配置文件的名字

What is the configuration file name?
To cancel, type 'none'. [none] 

输入之前创建配置文件的名字继续回车

To cancel, type 'none'. [none] bochsrc.disk
00000000000i[      ] reading configuration from bochsrc.disk
------------------------------
Bochs Configuration: Main Menu
------------------------------

This is the Bochs Configuration Interface, where you can describe the
machine that you want to simulate.  Bochs has already searched for a
configuration file (typically called bochsrc.txt) and loaded it if it
could be found.  When you are satisfied with the configuration, go
ahead and start the simulation.

You can also start bochs with the -q option to skip these menus.

1. Restore factory default configuration
2. Read options from...
3. Edit options
4. Save options to...
5. Restore the Bochs state from...
6. Begin simulation
7. Quit now

Please choose one: [6] 

继续回车
在这里插入图片描述
然后我们键入一个字符"c"并回车,如果不键入这个字符会一直卡在这个黑屏阶段
在这里插入图片描述
这里提示我们启动时找不到启动盘,既然找不到就创建一个

5:制作一个硬盘

我们可以使用bochs提供的创建虚拟磁盘的工具bin/bximage,先看一下该命令的帮助信息:bin/bximage --help

[kaiwen.denge@kaiwen bochs]$ bin/bximage --help
Usage: bximage [options] [filename1] [filename2]

Supported options:
  -mode=...     operation mode (create, convert, resize, commit, info)
  -fd=...       create: floppy image with size code
  -hd=...       create/resize: hard disk image with size in megabytes (M)
                or gigabytes (G)
  -imgmode=...  create/convert: hard disk image mode
  -sectsize=... create: hard disk sector size
  -b            convert/resize: create a backup of the source image
                commit: create backups of the base image and redolog file
  -q            quiet mode (don't prompt for user input)
  --help        display this help and exit

Other arguments:
  filename1     create:  new image file
                convert/resize: source image file
                commit:  base image file
  filename2     convert/resize: destination image file
                commit:  redolog (journal) file

帮助信息中详细的介绍了各个命令的作用,我就不再赘述了,直接开始创建虚拟硬盘

[kaiwen.denge@kaiwen bochs]$ bin/bximage
========================================================================
                                bximage
  Disk Image Creation / Conversion / Resize and Commit Tool for Bochs
         $Id: bximage.cc 13481 2018-03-30 21:04:04Z vruppert $
========================================================================

1. Create new floppy or hard disk image
2. Convert hard disk image to other format (mode)
3. Resize hard disk image
4. Commit 'undoable' redolog to base image
5. Disk image info

0. Quit

Please choose one [0] 1

Create image

Do you want to create a floppy disk image or a hard disk image?
Please type hd or fd. [hd] hd

What kind of image should I create?
Please type flat, sparse, growing, vpc or vmware4. [flat] flat

Choose the size of hard disk sectors.
Please type 512, 1024 or 4096. [512] 512

Enter the hard disk size in megabytes, between 10 and 8257535
[10] 200

What should be the name of the image?
[c.img] kernel.img

Creating hard disk image 'kernel.img' with CHS=203/16/63 (sector size = 1024)

The following line should appear in your bochsrc:
  ata0-master: type=disk, path="kernel.img", mode=flat

可以直接输入命令一次性创建,也可以键入bin/bochs回车按照提示创建,以上为我个人创建的硬盘信息仅供大家参考。
按照上述输出的最后一行提示信息,把"ata0-master: type=disk, path=“kernel.img”, mode=flat"加入到我们之前创建的配置文件。
继续我们的bin/bochs -f
在这里插入图片描述
额,好像还是不行,不过debug信息有变化,从could not read the boot disk ——>not a bootable disk。

6:总结

** 作者本人也是刚大学毕业,目前主要也在从事linux底层相关的工作,想朝着kernel方向发展,所以购买了一本《操作系统真象还原》的书,靠着下班自学。本文也是自己一步一步按照书中所述,再结合自身遇到的一些疑难杂症,做一个流程的梳理,即是方便自己以后忘记了好回顾,也是为想学习操作系统而苦恼的同学做一些经验的分享(不至于像我遇到问题还只能一个一个百度)。如果有问题欢迎指出改正,一起学习。**

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值