1.步骤
- 安装VMware15并安装虚拟机 Ubuntu18.04.3
- 安装git 和python
- 按照tools安装编译器工具链
- 编译jos系统并加载
输入命令: % objdump -i
第二行结果为elf32-i386
输入: % gcc -m32 -print-libgcc-file-name
结果为Command 'gcc' not found, but can be installed with:
安装gcc % sudo apt-get install -y build-essential gdb
输入
@ubuntu:~$ gcc -m32 -print-libgcc-file-name
结果成功
/usr/lib/gcc/x86_64-linux-gnu/7/libgcc.a
下载qemu
git clone https://github.com/mit-pdos/6.828-qemu.git qemu
还可需要安装libsdl1.2-dev、libtool-bin、libglib2.0-dev、libz-dev 和 libpixman-1-dev。
再输入:
1 % cd qemu/
2 % ./configure
3.% make
报错
CC qga/commands-posix.o
qga/commands-posix.c: In function ‘dev_major_minor’:
qga/commands-posix.c:633:13: error: In the GNU C Library, "major" is defined
by <sys/sysmacros.h>. For historical compatibility, it is
currently defined by <sys/types.h> as well, but we plan to
remove this soon. To use "major", include <sys/sysmacros.h>
directly. If you did not intend to use a system-defined macro
"major", you should undefine it after including <sys/types.h>. [-Werror]
*devmajor = major(st.st_rdev);
^~~~~~~~~~~~~~~~~~~~~~~~~~
qga/commands-posix.c:634:13: error: In the GNU C Library, "minor" is defined
by <sys/sysmacros.h>. For historical compatibility, it is
currently defined by <sys/types.h> as well, but we plan to
remove this soon. To use "minor", include <sys/sysmacros.h>
directly. If you did not intend to use a system-defined macro
"minor", you should undefine it after including <sys/types.h>. [-Werror]
*devminor = minor(st.st_rdev);
^~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
解决方法:
在 qga/commands-posix.c文件中加 #include <sys/sysmacros.h>
再报错:
block/blkdebug.c: In function ‘blkdebug_refresh_filename’:
block/blkdebug.c:749:31: error: ‘%s’ directive output may be truncated writing up to 4095 bytes into a region of size 4086 [-Werror=format-truncation=]
"blkdebug:%s:%s",
^~
In file included from /usr/include/stdio.h:862:0,
from /home/wzd/qemu/include/qemu-common.h:27,
from block/blkdebug.c:25:
/usr/include/x86_64-linux-gnu/bits/stdio2.h:64:10: note: ‘__builtin___snprintf_chk’ output 11 or more bytes (assuming 4106) into a destination of size 4096
return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
__bos (__s), __fmt, __va_arg_pack ());
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
/home/wzd/qemu/rules.mak:57: recipe for target 'block/blkdebug.o' failed
解决方法:config-host.mak文件中的-Werror去掉
4. % sudo make install
下载jos源码
git clone https://pdos.csail.mit.edu/6.828/2018/jos.git lab
% cd lab
% sudo make
报错:
ld: warning: section `.bss' type changed to PROGBITS
obj/kern/printfmt.o: In function `printnum':
lib/printfmt.c:41: undefined reference to `__udivdi3'
lib/printfmt.c:49: undefined reference to `__umoddi3'
kern/Makefrag:70: recipe for target 'obj/kern/kernel' failed
make: *** [obj/kern/kernel] Error 1
解决方法:
% sudo apt-get install gcc-4.8-multilib
再编译:
% sudo make
% sudo make qemu
终于成功
image.png
网友评论