这篇笔记是编译后根据记忆写下的,可能有遗漏^_^

基本流程如下:
2006/01/07: (看日期有些老了,不太适合最新版的0.90)
- URL of the Savannah CVS Server has been corrected.

2005/08/06:
- Added compilation steps for QVM86 accelerator (multiple changes from step 11 onwards).
- Added how to start and stop the QVM86 accelerator layer in Troubleshooting section.
- Added "--enable-adlib" switch on QEmu configure (step 12, thanks Ronald).
- Removed "SDL.dll" lines from steps 15 and 17, as it's not needed when QEmu is statically compiled (thanks Roland, again).
- Added tip about using full-screen with SDL_VIDEODRIVER=windib.

2005/07/25:
- Added cd command before downloading QEMU from CVS on step 10.
- Added advice about newer MinGW versions on the Tips section.

2005/06/11:
- Extract directx package before compiling QEMU (step 9 is now step 7).

2005/06/10:
- Added some tips on the top of the guide.
- Some corrections to the steps of the guide.
- Added a troubleshooting section at the end (including how to download a previous version from CVS!)

Before starting, some tips:

- You can copy the commands listed here and paste into Msys window using a middle-mouse click.
- You will see that Msys and Msys-DTK try to install on something like Msys\1.0. We don't need the 1.0 at all (it's the version number), that's why it's not listed in the guide.
- Newer MinGW versions (MinGW > v4.0) will compile an unworking QEMU executable. Please use the links provided below for a working MinGW version.

What you need:

- Some patience Razz
- MSYS-1.0.10.exe [ link ]
- msysDTK-1.0.1.exe [ link ]
- MinGW-3.1.0-1.exe [ link ]
- SDL-1.2.8.tar.gz [ link ]
- zlib-1.2.2.tar.gz [ link ]
- directx-devel.tar.gz [ link ]

1. Install MSYS-1.0.10.exe where you want (i.e: C:\Msys). When finished, you will see a system prompt asking if you wany to continue with post install. Type n so this isn't done.

2. Install msysDTK-1.0.1.exe in the same directory as MSYS-1.0.10.exe. (i.e: C:\Msys)

3. Install MinGW-3.1.0-1.exe under "mingw" folder inside your MSYS folder (i.e: C:\Msys\mingw). The installer will probably warn you the directory already exists, press Yes to install it there anyway.

4. Now you must open MSYS. Go to the directory where you installed MSYS, and run msys.bat (i.e: C:\Msys\msys.bat).

5. Type pwd in the MSYS window. It will show your home folder (/home/username).

6. With your preferred file manager (probably Windows Explorer, mine is Total Commander Smile ), copy:

Code:
SDL-1.2.8.tar.gz
zlib-1.2.2.tar.gz
directx-devel.tar.gz

under your home directory in MSYS folder (i.e: C:\Msys\home\username).

7. We must extract the directx devel package to mingw folder, as it's needed by SDL:

Code:
cd
tar -C /mingw -xzvf directx-devel.tar.gz

8. We will begin by installing SDL. Type the following in MSYS:

Code:
tar -xzvf SDL-1.2.8.tar.gz (this will extract SDL package)
cd SDL-1.2.8
./configure --prefix=/mingw
make
make install

It's possible that the ./configure command will try to connect to network (don't ask me why), you can safely block it.
This will compile and install SDL headers to the correct path (it takes some time, 8 min. on a fast computer).

9. Now you must go to home directory and extract zlib package:

Code:
cd
tar -xzvf zlib-1.2.2.tar.gz
cd zlib-1.2.2
./configure --prefix=/mingw
make test
make install

This will compile and install zlib headers to the correct path.

10. Now we will download QEMU from current CVS:

Code:
cd
export CVS_RSH="ssh"
cvs -z3 -d:pserver:anoncvs@cvs.savannah.nongnu.org:/cvsroot/qemu co qemu

You must answer "yes" when it asks if you want to continue connecting to CVS.
Once finished, enter QEMU folder using this command:

Code:
cd qemu

11. If you want, you can compile a kernel accelerator (QVM86) for QEmu (recommended). If not, you can skip this step.
We will download QVM86 from CVS, in a similar way we've done before with QEMU. Then we must apply the QVM86 patch to QEmu sources.
So you need to type the following commands:

Code:
cvs -z3 -d:pserver:anoncvs@cvs.savannah.nongnu.org:/cvsroot/qvm86 co qvm86
patch -p0 < qvm86/patch.qvm86

12. So we will finally start compiling QEmu at twelfth step. Wink Run the following commands:

Code:
./configure --target-list=i386-softmmu --static --enable-adlib

You must get the following output:

Code:
//这里略有不同,但是最好提示为yes的都要有
Install prefix    /c/Program Files/Qemu
BIOS directory    /c/Program Files/Qemu
binary directory  /c/Program Files/Qemu
Source path       /home/username/qemu
C compiler        gcc
make              make
host CPU          i386
host big endian   no
target list       i386-softmmu
gprof enabled     no
static build      yes
SDL support       yes
SDL static link   yes
mingw32 support   yes
Adlib support     no
FMOD support      no
kqemu             no
qvm86             yes

QVM86 will only be available if you followed step 11.
Take a look at SDL lines. If some of them are not supported ("no"), then it's probable you won't get graphical output. So go back to step 7.

13. This will configure only the i386 system emulator. If you want to compile all targets (i386, ppc, space, x86_64), then remove the --target-list argument from the previous ./configure command-line. You might have some problems, though.

//这一步在我的机器上没有必要
14. Now, we will start compiling QEMU by typing "make". It will probably stop saying it doesn't find texi2html and pod2man commands.
This is needed for building the man documentation. I don't need it at all, so I create a pair of void files instead and give them execution permissions. If you want the documentation, go search the packages yourself at Google. So:

Code:
echo -n >/bin/texi2html >/bin/pod2man
chmod 755 /bin/texi2html /bin/pod2man

15. Ok, type "make" again and if all goes well, it will finally compile QEMU. You will get a rather huge qemu.exe file (3 Mb) on i386-softmmu folder, so we will shrink using strip command. We will do the same with qemu-img.exe and SDL.dll library:

Code:
strip i386-softmmu/qemu.exe
strip qemu-img.exe

//在这里加上:
liuqi@EMACS ~/qemu/qvm86 进入qvm86所在的目录,执行下面的指令
$ make -f Makefile.winnt

16. If you download QVM86 in step 11, then you can also strip this driver file:

Code:
strip qvm86/qvm86.sys

Then, outside MSYS window, you must install QVM86 driver by right-click on qvm86.inf, then clicking "Install" from context menu.
If you installed MSYS in the default path, you will find this file in C:\Msys\home\username\qemu\qvm86.

17. And finally, you can close MSYS. Now you must copy the following files from your MSYS folder (i.e: C:\Msys) where you want (i.e: C:\QEmu) with your preferred file manager:

执行:
copy C:\msys\home\liuqi\qemu\i386-softmmu\qemu.exe c:\qemu
copy C:\msys\home\liuqi\qemu\qemu-img.exe c:\qemu
copy C:\msys\home\liuqi\qemu\pc-bios\bios.bin c:\qemu
copy C:\msys\home\liuqi\qemu\pc-bios\ppc_rom.bin c:\qemu
copy C:\msys\home\liuqi\qemu\pc-bios\vgabios.bin c:\qemu
copy C:\msys\home\liuqi\qemu\pc-bios\vgabios-cirrus.bin c:\qemu
copy C:\msys\home\liuqi\qemu\qvm86\qvm86.inf c:\qemu
copy C:\msys\home\liuqi\qemu\qvm86\qvm86.sys c:\qemu
copy C:\msys\home\liuqi\SDL-1.2.8\src\.libs\sdl.dll c:\qemu
即可

Code:
home/username/qemu/i386-softmmu/qemu.exe
home/username/qemu/qemu-img.exe
home/username/qemu/pc-bios/bios.bin
home/username/qemu/pc-bios/ppc_rom.bin
home/username/qemu/pc-bios/vgabios.bin
home/username/qemu/pc-bios/vgabios-cirrus.bin

安装完qvm86.inf后需要重新启动^_^

Troubleshooting:

- To start QVM86 accelerator, you must type the following command on a console window:

Code:
net start qvm86

When you've finished using QEmu, you can stop QVM86 accelerator using the following command:

Code:
net stop qvm86

- If you achieve to get QEmu compiled correctly, but after that, QEmu does not start, try to set SDL_VIDEODRIVER=windib before running QEmu.

- If QEmu crashes when going full-screen, then you must also try to set SDL_VIDEODRIVER=windib before running QEmu.

- If you have followed all the steps from the guide, but QEmu doesn't compile correctly, perhaps the current CVS has introduced some bugs that affect QEmu compilation.
In this case, we will need to compile a previous version from QEmu. So in step 10, we will download a previous version from CVS.
After exporting the CVS_RSH variable, we will execute the following statement:

Code:
cvs -z3 -d:ext:anoncvs@savannah.nongnu.org:/cvsroot/qemu co -D <YYYYMMDD> qemu

This will download the CVS version from the specified date <YYYYMMDD>. For example:

Code:
cvs -z3 -d:ext:anoncvs@savannah.nongnu.org:/cvsroot/qemu co -D 20050603 qemu

This will download QEMU version from June 3, 2005.

- Finally, you can reduce qemu executables and sdl library size a little more using an executable packer like UPX.

Good luck! Cool

PS: I will update this post according to the problems that you find while compiling and installing QEMU.
PS: Please inform me if you find gramatical errors, as I have an average english level.