Tutorial : How Compile Dosbox.

Anything gaming related that is not red and gooey goes in here.

Moderator: General Discussion Moderators

Post Reply
User avatar
Fresh_meat
Cultist
Posts: 91
Joined: Mon Dec 26, 2005 11:51 pm
Location: France

Tutorial : How Compile Dosbox.

Post by Fresh_meat »

You want get the better of your Dosbox ? You can try it.

What you need to get :

- Dosbox sources (or other)
- tar utility
- gunzip utility
- the latest version of gcc
- make utility or an IDE who can compilling with gcc
- a shell
- a text editor


What you need to know :

- the specifications of your CPU
- what is your gcc version
- if you have a 32 or a native 64 bits operating system


Before starting :

- gcc 3.x.x don't have the ssa optimisation unit so if you use that version, don't add the flag

Code: Select all

-fssa
- Apple power G4 and all cpu based on the same core don't support the third low-level optimisation level so if you have that kind of chip don't use the flag

Code: Select all

-O3
but

Code: Select all

-O2
- when I say for example "pentium4" it's also for all chip of this familly like celeron, pentium and xeon
- if you use an IDE, you must settle the optimisations in your IDE
- all of this optimisations are theoretically safe but you can try other by yourself
- the pipe flag is just to speed up the compilation
- the CHOST flag is specific to your operating system, take a look to the gcc man page
- if you don't have a 64 bit operating system, you need to use the 32 bits flags



* First you need to unpack the sources with gunzip, tar and you shell

Code: Select all

tar -xvzpf dosbox-0.65.tar.gz


* Now, go into the new directory

Code: Select all

cd dosbox-0.65


* If you use an IDE you need to creat a project, load all files and settle all your options, and make your project

* If you work with a shell you need to export 3 flags, see at the end to the specifications

Code: Select all

export CHOST="my flag"
export CFLAGS="my flag"
export CXXFLAGS="my flag"
* You must generate the makefile

Code: Select all

./configure
* Now take a look to the makefile and see if the flags are good, if there aren't, you must modify them with you text editor

Code: Select all

cat Makefile
emacs Makefile
#### Now the flags :twisted: of cause you need adjust the CHOST
  • - Pentium III

    CHOST="i686-pc-linux-gnu"
    CFLAGS="-march=pentium3 -O3 -pipe -fomit-frame-pointer -fmerge-all-constants -ffast-math -funswitch-loops -mmmx -msse -fssa"
    CXXFLAGS="${CFLAGS}"

    - Mobile Pentium III

    CHOST="i686-pc-linux-gnu"
    CFLAGS="-march=pentium3m -O3 -pipe -fomit-frame-pointer -fmerge-all-constants -ffast-math -funswitch-loops -mmmx -msse -fssa"
    CXXFLAGS="${CFLAGS}"

    - Pentium IV

    CHOST="i686-pc-linux-gnu"
    CFLAGS="-march=pentium4 -O3 -pipe -fomit-frame-pointer -fmerge-all-constants -ffast-math -funswitch-loops -mmmx -msse -msse2 -fssa"
    CXXFLAGS="${CFLAGS}"


    - Mobile Pentium IV

    CHOST="i686-pc-linux-gnu"
    CFLAGS="-march=pentium4m -O3 -pipe -fomit-frame-pointer -fmerge-all-constants -ffast-math -funswitch-loops -mmmx -msse -msse2 -fssa"
    CXXFLAGS="${CFLAGS}"

    - Pentium IV with 32 bits Presscot core

    CHOST="i686-pc-linux-gnu"
    CFLAGS="-march=pentium4m -O3 -pipe -fomit-frame-pointer -fmerge-all-constants -ffast-math -funswitch-loops -mmmx -msse -msse2 -msse3 -fssa"
    CXXFLAGS="${CFLAGS}"

    - Pentium IV with 32 bits Prescott core

    CHOST="i686-pc-linux-gnu"
    CFLAGS="-march=prescott -O3 -pipe -fomit-frame-pointer -fmerge-all-constants -ffast-math -funswitch-loops -mmmx -msse -msse2 -msse3 -fssa"
    CXXFLAGS="${CFLAGS}"

    - Athlon

    CHOST="i686-pc-linux-gnu"
    CFLAGS="-march=athlon -O3 -pipe -fomit-frame-pointer -fmerge-all-constants -ffast-math -funswitch-loops -mmmx -m3dnow -fssa"
    CXXFLAGS="${CFLAGS}"

    - Athlon-tbird

    CHOST="i686-pc-linux-gnu"
    CFLAGS="-march=athlon-tbird -O3 -pipe -fomit-frame-pointer -fmerge-all-constants -ffast-math -funswitch-loops -mmmx -m3dnow -fssa"
    CXXFLAGS="${CFLAGS}"

    - Athlon 4

    CHOST="i686-pc-linux-gnu"
    CFLAGS="-march=athlon-4 -O3 -pipe -fomit-frame-pointer -fmerge-all-constants -ffast-math -funswitch-loops -mmmx -m3dnow -msse -fssa"
    CXXFLAGS="${CFLAGS}"

    - Athlon XP

    CHOST="i686-pc-linux-gnu"
    CFLAGS="-march=athlon-xp -O3 -pipe -fomit-frame-pointer -fmerge-all-constants -ffast-math -funswitch-loops -mmmx -m3dnow -msse -fssa"
    CXXFLAGS="${CFLAGS}"

    - Athlon MP

    CHOST="i686-pc-linux-gnu"
    CFLAGS="-march=athlon-mp -O3 -pipe -fomit-frame-pointer -fmerge-all-constants -ffast-math -funswitch-loops -mmmx -m3dnow -msse -fssa"
    CXXFLAGS="${CFLAGS}"

    - Pentium IV with 64 bits Prescott core

    CHOST="x86_64-pc-linux-gnu"
    CFLAGS="-march=nocona -O3 -pipe -fomit-frame-pointer -fmerge-all-constants -ffast-math -funswitch-loops -mmmx -msse -msse2 -msse3 -fssa"
    CXXFLAGS="${CFLAGS}"

    - Opteron

    CHOST="x86_64-pc-linux-gnu"
    CFLAGS="-march=opteron -O3 -pipe -fomit-frame-pointer -fmerge-all-constants -ffast-math -funswitch-loops -mmmx -m3dnow -msse -msse2 -msse3 -fssa"
    CXXFLAGS="${CFLAGS}"

    - Athlon 64

    CHOST="x86_64-pc-linux-gnu"
    CFLAGS="-march=athlon64 -O3 -pipe -fomit-frame-pointer -fmerge-all-constants -ffast-math -funswitch-loops -mmmx -m3dnow -msse -msse2 -msse3 -fssa"
    CXXFLAGS="${CFLAGS}"

    - Athlon FX

    CHOST="x86_64-pc-linux-gnu"
    CFLAGS="-march=athlon-fx -O3 -pipe -fomit-frame-pointer -fmerge-all-constants -ffast-math -funswitch-loops -mmmx -m3dnow -msse -msse2 -msse3 -fssa"
    CXXFLAGS="${CFLAGS}"

    - G4 7400

    CHOST="powerpc-unknown-linux-gnu"
    CFLAGS="-mcpu=7400 -O2 -pipe -fsigned-char -maltivec
    -mabi=altivec -mpowerpc-gfxopt"
    CXXFLAGS="${CFLAGS}"

    - G4 7450

    CHOST="powerpc-unknown-linux-gnu"
    CFLAGS="-mcpu=7450 -O2 -pipe -fsigned-char -maltivec
    -mabi=altivec -mpowerpc-gfxopt"
    CXXFLAGS="${CFLAGS}"

    - G5

    CHOST="powerpc64-unknown-linux-gnu"
    CFLAGS="-mcpu=G5 -O3 -pipe -fsigned-char -maltivec
    -mabi=altivec -mpowerpc-gfxopt"
    CXXFLAGS="${CFLAGS}"
Thanks for your comments, remarks ...
Last edited by Fresh_meat on Fri Apr 28, 2006 08:18 am, edited 3 times in total.
User avatar
DustyStyx
2D Artist
Posts: 2038
Joined: Wed Aug 11, 2004 02:12 am
Location: Salt Lake
Contact:

Post by DustyStyx »

Thank you! This is verry informative, you get a sticky!
User avatar
Fresh_meat
Cultist
Posts: 91
Joined: Mon Dec 26, 2005 11:51 pm
Location: France

Post by Fresh_meat »

Thanks, of cause you can compil all other softwares like that ... Darkplaces for example.
User avatar
Jethro
Fanatic
Posts: 120
Joined: Mon Aug 16, 2004 05:01 pm
Location: Poland

Post by Jethro »

Damn, I've tried to follow your tips but... I've got executable that is much slower thn original one :/ I was using mingw+msys with P4 Prescott optimalisation with no luck. I've seen that CheapAlert was running Blood by setting core to dynamic and cycles to 40k, but my machine is unable to handle that much and I get 5-10 fps. Also, I was wondering about this CHOST settings: I've used i686-pc-windows-gnu, but ./configure detects "i686-pc-mingw32", so I was wondering if it was better to leave autodetected value instead of setting my own one.
So, anyone knows how to:

a) set up compiler to get faster exec/what could have I done wrong?
b) how to set up dosbox to get satisfying framerate?
User avatar
Fresh_meat
Cultist
Posts: 91
Joined: Mon Dec 26, 2005 11:51 pm
Location: France

Post by Fresh_meat »

a) set up compiler to get faster exec/what could have I done wrong?
I run dosbox on Gentoo Linux only so I don't know if you have settleed the good chost but I think you must use "i686-pc-mingw32"
b) how to set up dosbox to get satisfying framerate?
You need to find your own settle, it's very specific. For example, I have a P4C 3.0GHz under gentoo, first I settle "memory size" to 128, "core" to dynamic, cpu cycle to 25000, and 1 frameskipe, it's the best settle for my config, under and over I have a bad result.
Somethong else : Cryptic passage is very slow, so don't worry about it
Post Reply