龙空技术网

自制操作系统之一:Centos7.9 安装 bochs

技术分享 182

前言:

现在小伙伴们对“怎样在centos 7安装gcc”大约比较关切,朋友们都想要学习一些“怎样在centos 7安装gcc”的相关知识。那么小编在网络上搜集了一些有关“怎样在centos 7安装gcc””的相关资讯,希望兄弟们能喜欢,小伙伴们快快来学习一下吧!

自制操作系统第一步,就是搭建模拟环境,方便调试和运行。Bochs是一个x86硬件平台的开源模拟器。可以模拟各种硬件配置,包括CPU、内存、硬盘、显示器、以太网、BIOS等常见硬件以及整个PC平台,以下是bochs-2.6.8在Centos 7.9环境下的安装过程。

一、安装依赖

一次性安装好所需依赖,避免后续报错处理。

yum install gtk2 gtk2-devel libXt \libXt-devel libXpm libXpm-devel SDL SDL-devel \libXrandr-devel.x86_64 xorg-x11-server-devel \glibc-headers gcc-c++ SDL SDL-devel
二、下载安装文件

下载bochs源码并解压

# 下载资源页:  下载源码wget ";# 解压文件tar -zxvf bochs-2.6.8.tar.gz
三、编译安装3.1、运行环境配置

打开bochs-2.6.8目录下隐藏文件 .bochsrc,可以定制软件配置。一般使用默认配置,以下是一些关键参数,可以根据自己需要进行调整。

#相当于设置BIOS的启动项,此处为软盘启动。boot:floppy# 表示设置插入软盘的类型为容量1.44 MB的软盘,软盘镜像文件的文件名为boot.img,状态是已经插入,写保护开关置于关闭状态。floppya:type=1_44,1_44="boot.img", status=inserted,write_protected=0# cpu配置cpu: model=core2_penryn_t9600, count=1, ips=50000000, reset_on_triple_fault=1, ignore_bad_msrs=1, msrs="msrs.def"cpu: cpuid_limit_winnt=0#cpuid配置cpuid: x86_64=1, mmx=1, sep=1, simd=sse4_2, apic=xapic, aes=1, movbe=1, xsave=1cpuid: family=6, model=0x1a, stepping=5# 设置可用物理内存容量,以MB为单位,目前Bochs软件可用的内存上限是2048 MBmegs:2048# 关闭声卡驱动,如果是ECS环境,没有安装声卡模块,可以关闭这个配置# sound: driver=default, waveout=/dev/dsp. wavein=, midiout=
3.2、配置检查

进入安装目录,完成bonchs配置。如果配置过程中出现报错,可以参考 五、异常处理 模块解决。

cd bochs-2.6.8./configure --with-x11 --with-wx --enable-debugger --enable-disasm \--enable-all-optimizations --enable-readline --enable-long-phy-address \--enable-ltdl-install --enable-idle-hack --enable-plugins --enable-a20-pin \--enable-x86-64 --enable-smp --enable-cpu-level=6 --enable-large-ramfile \--enable-repeat-speedups --enable-fast-function-calls  --enable-handlers-chaining \--enable-trace-linking --enable-configurable-msrs --enable-show-ips --enable-cpp \--enable-debugger-gui --enable-iodebug --enable-logging --enable-assert-checks \--enable-fpu --enable-vmx=2 --enable-svm --enable-3dnow --enable-alignment-check  \--enable-monitor-mwait --enable-avx  --enable-evex --enable-x86-debugger \--enable-pci --enable-usb --enable-voodoo
3.3、编译安装

执行编译安装,等待安装结束。如果安装过程中出现报错,常见的报错信息,也可以参考 五、异常处理 模块解决。

make install
3.4、验证安装结果

在安装目录执行 ./bochs 命令,出现以下结果,即为安装成功。

[root@centos7.9 bochs-2.6.8]# ./bochs# 正常输出如下:========================================================================                       Bochs x86 Emulator 2.6.8                Built from SVN snapshot on May 3, 2015                  Compiled on Mar 23 2024 at 22:27:20========================================================================00000000000i[      ] LTDL_LIBRARY_PATH not set. using compile time default '/usr/local/lib/bochs/plugins'00000000000i[      ] BXSHARE not set. using compile time default '/usr/local/share/bochs'00000000000i[      ] lt_dlhandle is 0x1878fb000000000000i[PLUGIN] loaded plugin libbx_unmapped.so00000000000i[      ] lt_dlhandle is 0x1879a8000000000000i[PLUGIN] loaded plugin libbx_biosdev.so00000000000i[      ] lt_dlhandle is 0x187a43000000000000i[PLUGIN] loaded plugin libbx_speaker.so00000000000i[      ] lt_dlhandle is 0x187b29000000000000i[PLUGIN] loaded plugin libbx_extfpuirq.so00000000000i[      ] lt_dlhandle is 0x187bb0000000000000i[PLUGIN] loaded plugin libbx_parallel.so00000000000i[      ] lt_dlhandle is 0x187d6e000000000000i[PLUGIN] loaded plugin libbx_serial.so00000000000i[      ] lt_dlhandle is 0x18819d000000000000i[PLUGIN] loaded plugin libbx_iodebug.so00000000000i[      ] reading configuration from .bochsrc00000000000e[      ] .bochsrc:714: ataX-master/slave CHS set to 0/0/0 - autodetection enabled00000000000e[      ] .bochsrc:918: invalid choice 'sound' parameter 'mode'00000000000e[PCSPK ] .bochsrc:918: unknown parameter for speaker ignored.------------------------------Bochs Configuration: Main Menu------------------------------This is the Bochs Configuration Interface, where you can describe themachine that you want to simulate.  Bochs has already searched for aconfiguration file (typically called bochsrc.txt) and loaded it if itcould be found.  When you are satisfied with the configuration, goahead and start the simulation.You can also start bochs with the -q option to skip these menus.1. Restore factory default configuration2. Read options from...3. Edit options4. Save options to...5. Restore the Bochs state from...6. Begin simulation7. Quit nowPlease choose one: [6]

四、配置环境变量

配置好环境变量,后续在系统即可直接使用,而不需要进入安装目录运行。

vim  ~/.bash_profileexport BXSHARE=/usr/local/share/bochssource ~/.bash_profile
五、异常处理5.1 配置报错
configure: error: in `/root/os_demo/bochs-2.6.2':configure: error: C++ preprocessor "/lib/cpp" fails sanity check  # 解决方案: 安装 gcc-c++yum install gcc-c++
5.2、找不到头文件
x.cpp:37:22: fatal error: X11/Xlib.h: No such file or directory 或者x.cpp:42:35: fatal error: X11/extensions/Xrandr.h: No such file or directory  # 解决方案: 安装 libX* 相关组件yum install libX*
5.3、找不到 .cc 文件
make: *** 没有规则可以创建“misc/bximage.o”需要的目标“misc/bximage.cc”。 停止。# 解决方案:缺少对应 .cc 文件, 复制以下 .cpp文件为 .cc 后缀文件即可cp misc/bximage.cpp misc/bximage.cccp iodev/hdimage/hdimage.cpp iodev/hdimage/hdimage.cccp iodev/hdimage/vmware3.cpp iodev/hdimage/vmware3.cccp iodev/hdimage/vmware4.cpp iodev/hdimage/vmware4.cccp iodev/hdimage/vpc-img.cpp iodev/hdimage/vpc-img.cccp iodev/hdimage/vbox.cpp iodev/hdimage/vbox.cc
5.4、运行 ./bochs 报错
.bochsrc:907: Bochs is not compiled with lowlevel sound support# 解决方案:缺少声音相关设备支持,打开 .bochsrc 文件,注释sound相关配置,再重新编译vim .bochsrc # sound: driver=default, waveout=/dev/dsp. wavein=, midiout=

至此,已经安装好bochs模拟软件啦,待后续开发调试使用。

标签: #怎样在centos 7安装gcc