Step-by-step QEMU compilation under Windows (MinGW/MSYS)

using QEMU howto's - how to install a guest OS under QEMU, etc - people are more then welcome to submit any documents they written and share them with the community

Step-by-step QEMU compilation under Windows (MinGW/MSYS)

Postby comike on Thu Jul 14, 2005 1:52 am

Updates to this guide:

2006/01/07:
- 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 :P
- 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 :) ), copy:

Code: Select all
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: Select all
cd
tar -C /mingw -xzvf directx-devel.tar.gz

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

Code: Select all
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: Select all
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: Select all
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: Select all
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: Select all
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. ;) Run the following commands:

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

You must get the following output:

Code: Select all
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: Select all
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: Select all
strip i386-softmmu/qemu.exe
strip qemu-img.exe

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

Code: Select all
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:

Code: Select all
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

Troubleshooting:

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

Code: Select all
net start qvm86

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

Code: Select all
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: Select all
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: Select all
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! 8)

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.
Last edited by comike on Sat Jan 07, 2006 9:19 pm, edited 7 times in total.
Take a look at QGui - QEmu Launcher
Compile QEmu for Windows from CVS following this guide.
User avatar
comike
helper
 
Posts: 48
Joined: Mon Jun 27, 2005 1:18 pm
Location: Spain

Postby DreckSoft on Sun Jul 24, 2005 1:29 am

Small but important note:
It will not work with MinGW 4.1.1
Compilation works fine but qemu will crash instantly (tried 03.06.05, 01.07.05 and 23.07.05).
23.07.05 works with MinGW 3.1.0 (and even with qvm86 patch)
DreckSoft
 
Posts: 1
Joined: Sun Jul 24, 2005 1:05 am

What a wonderful howto!!!

Postby Glomet on Mon Jul 25, 2005 2:36 pm

comike... thank you very much for this very precious resource!!!
It helped me saving a lot of hours of tries and retries!!!

Just a really little correction:

following your instructions, at step 10 you suggest how to download the sources, but at step 9 we were CD'ed to ~/zlib-1.2.2, so, at step 10, the cvs image is downloaded in ~/zlib-1.2.2/qemu, and not in ~/qemu as instead it would be expected to be.

So I suggest you to correct step 10 simply adding the usual "cd" command at the beginning of the code-lines.

Thank you again, your howto is really as simple as a step-forward, and it took me to have the qemu compilated in really a few minutes!!

Cheers
- Umberto
Glomet
 
Posts: 10
Joined: Wed Jul 20, 2005 3:45 pm

Postby comike on Mon Jul 25, 2005 4:28 pm

Thanks for your advice, Glomet. :wink:

I will add the cd command in step 10 and the remark from DreckSoft about latest MinGW.
Take a look at QGui - QEmu Launcher
Compile QEmu for Windows from CVS following this guide.
User avatar
comike
helper
 
Posts: 48
Joined: Mon Jun 27, 2005 1:18 pm
Location: Spain

Re: Step-by-step QEMU compilation under Windows (MinGW/MSYS)

Postby Guest on Fri Jul 29, 2005 11:44 am

comike wrote:Updates to this guide:

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


Thankx for your teaching. :D

But I have a questing:
If want to compile Kqemu with Qemu under Windows,
how can I do?

Can you kindly teaching again? :P
Guest
 

Postby comike on Fri Jul 29, 2005 12:59 pm

Of course I can. I was already thinking on writing how to compile qvm86.

I will do as soon as I get some free time.
Take a look at QGui - QEmu Launcher
Compile QEmu for Windows from CVS following this guide.
User avatar
comike
helper
 
Posts: 48
Joined: Mon Jun 27, 2005 1:18 pm
Location: Spain

some comments

Postby Ronald on Sat Jul 30, 2005 1:46 pm

Hi,

I don't use msys so don't blame me if the following tips doesn't work at all.

-SDL and directx (step 7 and 8)

you can get a more optimized SDL library if you install/use nasm for SDL compilation, maybe it is shipped with msys (dont know???)
About directx , look at the configure output near the end , before Makefiles create you should see if directx support will be build in.

here is how I do (SDL-1.2.8 is in /usr/src), needed libraries are installed with mingw32 or win32api, no need to copy the whole directx-devel content.

Code: Select all
CPPFLAGS='-I/usr/src/win32/directx/include -I/usr/src/win32/SDL-1.2.8/src/video/windx5' ./configure --prefix=/cross/mingw32/i386-mingw32 --enable-shared --build=i686-pure-linux --host=i386-mingw32 --disable-debug --program-prefix=i386-mingw32-


-zlib (step 9)

look in the win32 directory there is a Makefile.gcc , you can use this one to build libz.a, libzdll.a and zlib1.dll , need to be edited.

Code: Select all
make -f win32/Makefile.gcc


-qemu configure and build (step 11)

you can add --enable-adlib to have midi support in qemu, --static flag is not really needed since you are copying SDL.dll later.
Instead of coying all the binaries (step 15) , it 's better to use the make install target , this will strip qemu*.exe , you only need to strip SDL.dll at step 14
[/code]
Ronald
 
Posts: 5
Joined: Sun Jul 03, 2005 1:03 am
Location: Marseille (France)

Updated!

Postby comike on Sat Aug 06, 2005 2:11 am

As you can see, I've updated my guide. It now includes new steps on how to compile QVM86 accelerator layer, and I've made some fixing here and there.

Hope it helps (and works! :wink:)
Take a look at QGui - QEmu Launcher
Compile QEmu for Windows from CVS following this guide.
User avatar
comike
helper
 
Posts: 48
Joined: Mon Jun 27, 2005 1:18 pm
Location: Spain

Postby Guest on Sat Aug 06, 2005 2:38 pm

Step 11:

Line
Code: Select all
cvs -z3 -d:ext:anoncvs@savannah.nongnu.org:/cvsroot/qemu co qemu


should be
Code: Select all
cvs -z3 -d:ext:anoncvs@savannah.nongnu.org:/cvsroot/qvm86 co qvm86


Stefan
Guest
 

Postby vbtricks on Sat Aug 06, 2005 3:12 pm

It's me again (the Guest from the reply in front of this one).

I tried compiling it with qvm86, but unfortunately the make command in step 15 fails (kqemu.c line 438).

Also tried to compile a version with support for kqemu (by changing all
kqemu="no"

to
kqemu="yes"

).
The second one compiled successfully and "info kqemu" in the monitor returned "kqemu is enabled". I also followed the steps to install kqemu and started it by "net start kqemu" (returned success). But the guest system is not a bit faster at all.


What am I doing wrong?

Stefan
vbtricks
 
Posts: 2
Joined: Sat Aug 06, 2005 2:35 pm

Postby comike on Sat Aug 06, 2005 10:00 pm

vbtricks wrote:Step 11: ...

I thought I'd already fixed that mistake. Now it's fixed. Thanks for your advice.

About QVM86 compiling, I had the same problem in kemu.c yesterday while compiling QEmu+QVM86.
I made a workaround adding lines 437 and 441 as shown below:
Code: Select all
437 #ifndef _WIN32
438 #if KQEMU_VERSION >= 0x010100
439     kenv->efer = env->efer;
440 #endif
441 #endif

Hope it helps.

About speed, KQEmu speeds some processor calculations, I think. But the real bottleneck stays on File I/O and graphics, where KQEmu does nothing. :cry:
Take a look at QGui - QEmu Launcher
Compile QEmu for Windows from CVS following this guide.
User avatar
comike
helper
 
Posts: 48
Joined: Mon Jun 27, 2005 1:18 pm
Location: Spain

Postby vbtricks on Sun Aug 07, 2005 2:47 pm

Thanks, I succeeded in compiling.

Unfortunately it doesn't bring the speed advantage I thought it would. Thanks anyway.


Stefan
vbtricks
 
Posts: 2
Joined: Sat Aug 06, 2005 2:35 pm

Binary download

Postby Guest on Thu Aug 11, 2005 4:11 pm

comike,

Can you supply the download its last compilation of QEMU+qvm86 in some place?
Guest
 

Postby mok on Sat Aug 13, 2005 4:36 pm

vbtricks wrote:Thanks, I succeeded in compiling.

Unfortunately it doesn't bring the speed advantage I thought it would. Thanks anyway.


Stefan


I compiled qemu (0.7.1, not from cvs) + kqemu. I didn't enable qvm86, but even without it guest OS works much faster now, so I'm able to run KDE 3.4.2 on Slackware - slow, but pretty acceptable.
mok
 
Posts: 5
Joined: Fri Aug 05, 2005 3:04 am

Re: Binary download

Postby mok on Sat Aug 13, 2005 8:08 pm

qemu 0.7.1 built with kqemu support is available here:

http://byak.sinp.msu.ru/qemu/

Unzip qemu.exe and use it as usual.

Don't forget to start the kqemu service from Windows command prompt:

Code: Select all
> net start kqemu


Check if kqemu support is available on qemu console (Ctrl+Alt+2),
Code: Select all
> info kqemu
mok
 
Posts: 5
Joined: Fri Aug 05, 2005 3:04 am

Next

Return to HOWTOs

Who is online

Users browsing this forum: No registered users and 2 guests