6.828 | 编译QEMU

环境:Windows 和 ubuntu18.04双系统

步骤(按照官方文档):

在自己建的6.828文件夹(方便管理)里输入命令:

git clone https://github.com/geofft/qemu.git -b 6.828-1.7.0

Clone完毕之后进入qemu文件夹输入命令

./configure --disable-kvm [--prefix=PFX] [--target-list="i386-softmmu x86_64-softmmu"]

 在这里我遇到了第一个问题(报错信息现在已经找不到了):

这里需要用python2.7,但是我的ubuntu里只有python3,所以需要先下载python2.7,然后将python2软链接为python

问题解决!

 

进行环境配置,如果一切正常则输入命令

make&make install

进行编译

 

然后……问题就来了!

我在进行编译的时候就出现了问题

输入命令:

make

出现如下报错:

@fabrice ➜ qemu git:(master) ✗ make
  GEN   i386-softmmu/config-devices.mak.tmp
/bin/sh: 1: cannot create i386-softmmu/config-devices.mak.tmp: Permission denied
  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
/home/fabrice/6.828/qemu/rules.mak:57: recipe for target 'qga/commands-posix.o' failed
make: *** [qga/commands-posix.o] Error 1

Google了很久都没有找到方法(再次吐槽某度),在大佬的指导下最终解决:

根据报错信息在文件 qga/commands-posix.c 中只include了<sys/types.h>,但是我们需要<sys/sysmacros.h>文件

所以我们只需要打开 文件qga/commands-posix.c,然后在其中添加如下代码:

#include <sys/sysmacros.h>

成功解决!

但是……

再次make

又遇到了新的问题

报错信息如下:

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/fabrice/6.828/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/fabrice/6.828/qemu/rules.mak:57: recipe for target 'block/blkdebug.o' failed
make: *** [block/blkdebug.o] Error 1

将 config-host.mak 文件中的相关Werror文件删除之后就不会再有报错信息

  • 5
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 6
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值