学习操作系统,下载了bochs最新版本,但是不会编译安装,老是出错,用了一会简单的无调试功能的bochs但是感觉缺少点什么,想用带调试功能的,网上搜索了好多资料,终于自己完成了编译安装的bochs,不容易啊,赶紧分享一下,linux版本是Ubuntu 9.04 虚拟己版本是bochs 2.4.1
不带调试功能的简单安装方法:
sudo apt-get install bochs
带调试功能的bochs安装
sudo apt-get install build-essential 安装编译环境
tar vxzf bochs-2.4.1.tar.gz
cd bochs-2.3.5
./configure –enable-debugger –enable-disasm
这一步问题出来了,没注意配置时出现的问题就接着make了,导致make的时候,老是说83行遗漏分隔符。后来注意到了configure 的时候最后一行出现了一句:
> ERROR: X windows gui was selected, but X windows libraries were not found.
后来解决了,sudo aptitude install xorg-dev
When install bochs, While I compile come file with ./configure there give a msg:
> configure: WARNING: Bochs for wxWidgets cannot be compiled here, disabling it
> checking for default gui on this platform… x11
> ERROR: X windows gui was selected, but X windows libraries were not found.
I just follow this :
You need to install the development libraries. To compile a wxWidgets
program you need libwxbase2.4-dev, libwxbase2.4-dev, and
libwxgtk2.4-contrib-dev (for a wx2.4 program) or libwxgtk2.6-dev (for a
wx2.6 program). For an X11 program you need x-window-system-dev, which
should pull in all the dependencies you need.
but I couldn’t install the x-window-system-dev with: sudo apt-get install x-window-system-dev
the to solved this just:
sudo aptitude install xorg-dev everything is fine with the ./configure now .
sudo apt-get install xorg-dev无法安装,吼吼,又学到了个aptitude 。
再./configure 试试,晕,又有错误,错误提示是
checking for display libraries… X11
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 variable
No package ‘gtk+-2.0’ found
ERROR: 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).
这个安装了个 gtk就解决了
sudo aptitude install libgtk2.0-dev (这个是自己猜的,安装上果然可以了,呵呵,还有点天分)
然后make,make 的时候也出了点问题。
proc_ctrl.cc:654: 错误: ‘CheckPDPTR’在此作用域中尚未声明
proc_ctrl.cc:668: 错误: ‘CheckPDPTR’在此作用域中尚未声明
make[1]: *** [proc_ctrl.o] 错误 1
make[1]:正在离开目录 `/media/disk-1/Linux/bochs-2.4.1/cpu’
make: *** [cpu/libcpu.a] 错误 2
上网搜的是那个文件出了错proc_ctrl.cc
make时的错误
proc_ctrl.cc:654: error: ‘CheckPDPTR’ was not declared in this scope
proc_ctrl.cc:668: error: ‘CheckPDPTR’ was not declared in this scope
make[1]: *** [proc_ctrl.o] Error 1
GCC版本gcc (Ubuntu 4.3.3-5ubuntu4) 4.3.3
自己解决:
代码:
650行开始
#if BX_SUPPORT_VMX
VMexit_CR3_Write(i, val_32);
if (BX_CPU_THIS_PTR cr0.get_PG() && BX_CPU_THIS_PTR cr4.get_PAE() &&
!long_mode()) {
if (! CheckPDPTR(val_32)) {
BX_ERROR((“SetCR3(): PDPTR check failed !”));
exception(BX_GP_EXCEPTION, 0, 0);
}
}
SetCR3(val_32);
BX_INSTR_TLB_CNTRL(BX_CPU_ID, BX_INSTR_MOV_CR3, val_32);
break;
#endif
#if BX_CPU_LEVEL > 3
case 4: // CR4
#if BX_SUPPORT_VMX
val_32 = VMexit_CR4_Write(i, val_32);
if (BX_CPU_THIS_PTR cr0.get_PG() && (val_32 & (1<<5)) != 0 /* PAE */
&& !long_mode()) {
if (! CheckPDPTR(BX_CPU_THIS_PTR cr3)) {
BX_ERROR((“SetCR4(): PDPTR check failed !”));
exception(BX_GP_EXCEPTION, 0, 0);
}
}
// Protected mode: #GP(0) if attempt to write a 1 to
// any reserved bit of CR4
if (! SetCR4(val_32))
exception(BX_GP_EXCEPTION, 0, 0);
break;
#endif
#endif
default:
BX_ERROR((“MOV_CdRd: #UD – control register %d index out of range”,
i->nnn()));
exception(BX_UD_EXCEPTION, 0, 0);
}
}
683结束
代码:
@@ -649,7 +649,6 @@
case 3: // CR3
#if BX_SUPPORT_VMX
VMexit_CR3_Write(i, val_32);
-#endif
if (BX_CPU_THIS_PTR cr0.get_PG() && BX_CPU_THIS_PTR cr4.get_PAE() && !long_mode()) {
if (! CheckPDPTR(val_32)) {
BX_ERROR((“SetCR3(): PDPTR check failed !”));
@@ -659,11 +658,11 @@
SetCR3(val_32);
BX_INSTR_TLB_CNTRL(BX_CPU_ID, BX_INSTR_MOV_CR3, val_32);
break;
+#endif
#if BX_CPU_LEVEL > 3
case 4: // CR4
#if BX_SUPPORT_VMX
val_32 = VMexit_CR4_Write(i, val_32);
-#endif
if (BX_CPU_THIS_PTR cr0.get_PG() && (val_32 & (1<<5)) != 0 /* PAE */ && !long_mode()) {
if (! CheckPDPTR(BX_CPU_THIS_PTR cr3)) {
BX_ERROR((“SetCR4(): PDPTR check failed !”));
@@ -676,6 +675,7 @@
exception(BX_GP_EXCEPTION, 0, 0);
break;
#endif
+#endif
default:
BX_ERROR((“MOV_CdRd: #UD – control register %d index out of range”, i->nnn()));
exception(BX_UD_EXCEPTION, 0, 0);
问题6:
install: 无法获取”./bochsdbg” 的文件状态(stat): 没有该文件或目录
解决办法:需要在make后,将bochs拷贝一份,命名为bochsdbg
make问题解决了,然后
sudo make install 就可以了