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 . For historical compatibility, it is
 currently defined by  as well, but we plan to
 remove this soon. To use "major", include 
 directly. If you did not intend to use a system-defined macro
 "major", you should undefine it after including . [-Werror]
         *devmajor = major(st.st_rdev);
             ^~~~~~~~~~~~~~~~~~~~~~~~~~                                                                                                                                                                                                                                                                                                                                              
qga/commands-posix.c:634:13: error: In the GNU C Library, "minor" is defined
 by . For historical compatibility, it is
 currently defined by  as well, but we plan to
 remove this soon. To use "minor", include 
 directly. If you did not intend to use a system-defined macro
 "minor", you should undefine it after including . [-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了,但是我们需要文件

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

#include 

成功解决!

但是……

再次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文件删除之后就不会再有报错信息

你可能感兴趣的:(Linux)