Difference between revisions of "Building DOSBox with MinGW"

From DOSBoxWiki
Jump to navigationJump to search
(Major rewrite, I used Windows XP as the base OS. Current as of October 2014)
Line 1: Line 1:
 
== Building your own version of DOSBox ==
 
== Building your own version of DOSBox ==
  
Why to do this?<br>
+
MinGW is the development environment that this page will show you how to use, an alternative is to use [[Building_DOSBox_with_Visual_C_2008_Express|Microsoft Visual Studio]]
Because any resource-intensive program can benefit greatly from optimization for your exact processor.<br>
 
[[System_Requirements|System Requirements]] states that a P3 1Ghz can emulate a 3/486 - early dos games. I have compiled Dosbox and SDL myself for this processor, 1Ghz P3, and I can run games from 95/96 OK (Caesar 2, C&C: Red Alert).
 
So, if you have the skill, the performance increase is recommended.
 
  
 +
This page will guide you through setting up MinGW to compile a current (SVN/CSV) version of DOSBox. Because of updates to compilers and libraries, this guide will not work with the 0.74 (the last official release, which is currently over 4 years old) source files.
  
=== 1. Grab the source ===
+
== Installing MinGW ==
 +
* Download mingw-get-setup.exe from http://sourceforge.net/projects/mingw/
 +
* Run the installer, choosing the defaults
 +
* Once the '''MinGW Installation Manager''' application starts, select
 +
** mingw-developer-toolkit (msys-base should be automatically added)
 +
** mingw32-base
 +
** mingw32-gcc-g++
 +
* On the installation menu, apply changes, and confirm that you want to apply the changes
  
First, grab the latest version of the DOSBox source code. A fairly often updated SVN-Dump can be found at: http://source.dosbox.com/dosboxsvn.tgz
+
The installation manager is going to download a bunch of files, and at the end, start installing them. Once this is done, you can close the dialog box as well as the installation manager.
  
Download it and extract it to a separate directory.
+
Well done, MinGW is now installed! Let's start it up.
  
=== 2. SDL ===
+
* Browse to '''C:\MinGW\msys\1.0'''
 +
* Run '''MSYS.BAT'''
  
DOSBox uses SDL (Simple DirectMedia Layer) to access your graphics and sound hardware, so you'll need to download it as well. Grab the latest source at
+
This will start up a DOS prompt like screen, lets mount the base path
 +
  mount 'c:\MinGW' /mingw
  
: http://www.libsdl.org/
+
You have now completed this section, lets move on to adding the SDL libraries to MinGW.
  
and extract to a separate directory.
+
== Adding the SDL libraries to MinGW ==
 +
* Download the pre compiled SDL development libraries from here http://www.libsdl.org/release/SDL-devel-1.2.15-mingw32.tar.gz
 +
* Copy the downloaded file to your MSYS home folder, it's going to be something like '''C:\MinGW\msys\1.0\home\Administrator'''
 +
* Switch back to the MSYS command prompt we started earlier
 +
* Lets extract the downloaded files
 +
  tar xvf SDL-devel-1.2.15-mingw32.tar.gz
 +
* And now add the files to MinGW
 +
  cd SDL-1.2.15
 +
  make native
 +
  cd ..
  
When working on Windows, you might want to save a lot of effort and just use the SDL (and optionally SDL_net) .DLL files included with the latest official DOSBox release, as compiling SDL with full options (e.g. DirectX support) is a bit involved. There are also pre-built .DLL files on the SDL web site (Runtime Libraries -> Win32) that you can try at
+
Cool, the SDL libraries have been added to MinGW, onto the next section.
  
: http://www.libsdl.org/download-1.2.php
+
== Adding Direct Draw support to DOSBox (Optional) ==
 +
If you want to give DOSBox the option to use the DDRAW output option, then we need to add a couple of extra libraries to MinGW
 +
* Download the following file, http://www.libsdl.org/extras/win32/common/directx-devel.tar.gz
 +
* Copy the downloaded file to your MSYS home folder
 +
* Switch to the MSYS command prompt
 +
* Extract the files (the -C parameter, tells tar where to extract the files to)
 +
  tar xvf directx-devel.tar.gz -C /mingw
  
Note that as of 12 Dec 2004, ddraw (DirectDraw) rendering mode will not work in DOSBox unless you either use the SDL.dll included with the latest version of DOSBox, or build your own SDL.dll with the changes mentioned in the "Compiling SDL" section below.
+
== Adding SDL_net libraries to MinGW (Optional) ==
 +
SDL_net gives DOSBox networking support, if you aren't going to be using DOSBox for multi player games, then you can probably skip this step.
 +
* Download the SDL_net source files from https://www.libsdl.org/projects/SDL_net/release/SDL_net-1.2.8.tar.gz
 +
* Copy the downloaded file to your MSYS home folder
 +
* Switch to the MSYS command prompt
 +
* Extract the file
 +
  tar xvf SDL_net-1.2.8.tar.gz
 +
* Lets configure the libraries
 +
  cd SDL_net-1.2.8
 +
  ./configure prefix=/usr
 +
* And now compile them
 +
  make
 +
* And then install them (copy the files)
 +
  make install
 +
  cd ..
  
=== 3. Compiling environment ===
+
== Compiling DOSBox ==
 +
* Download the latest source files for DOSBox from here http://source.dosbox.com/dosboxsvn.tgz
 +
* Copy the file to your MSYS home folder
 +
* Extract the file
 +
  tar xvf dosboxsvn.tgz
 +
* Let's configure it
 +
  cd dosbox
 +
  ./autogen.sh
 +
  ./configure LDFLAGS="-static-libgcc -static-libstdc++ -s"
 +
* And now for compiling DOSBox
 +
  make
 +
* The last step is to gather all the files together in a folder
 +
** Create a folder with a name of your choosing
 +
** Copy the dosbox.exe file located under the '''dosbox\src''' folder, e.g. '''C:\MinGW\msys\1.0\home\Administrator\dosbox\src''' to the folder you created
 +
** Copy the SDL.dll file located under '''SDL-1.2.15\bin''', e.g. '''C:\MinGW\msys\1.0\home\Administrator\SDL-1.2.15\bin''' to the folder you created
 +
** Optionally, copy the SDL_net.dll file located under '''SDL_net-1.2.8\.libs''', e.g. '''C:\MinGW\msys\1.0\home\Administrator\SDL_net-1.2.8\.libs''' to the folder you created
  
When working on Windows, you'll most likely need a compiling environment. We suggest using the combination of MinGW and MSYS, which can be found at
+
Start up DOSBox, and see if it works.
 
 
: http://prdownloads.sf.net/mingw/
 
 
 
You'll need to download both the latest MinGW and MSYS. After downloading, install MinGW and MSYS (in this order). The MSYS-Installer should ask for the installation directory of MinGW, so you should pick the path where you installed it. After the installation, run the MSYS.BAT and you should see a unix-like command prompt.
 
 
 
Warning!  The latest MinGW comes with version 4.7.2 of gcc and g++.  For some people this will end up resulting in a version of DOSBox that compiles fine but hangs when issued any command, like the "mount" command.  If this is happening to you, try using an older version of gcc like so:
 
 
 
Go into the MinGW shell and do:
 
<pre>
 
mingw-get remove gcc
 
mingw-get remove g++
 
mingw-get install gcc=4.5.2-1
 
mingw-get install g++=4.5.2-1
 
</pre>
 
 
 
Also, if you do use an older version of gcc/g++, you'll need to make sure that DOSBOX.EXE, when run, is in a directory with compatible gcc/g++ DLLs.  The easiest way to insure this is to copy <code>libgcc_s_dw2-1.dll</code> and <code>libstdc++-6.dll</code> from the MinGW/bin directory to your DOSBOX directory.
 
 
 
=== 4. Compiling SDL ===
 
 
 
Navigate to the directory where you extracted the SDL-source (using unix commands) and type
 
 
 
./configure
 
make
 
make install
 
 
 
Some MinGW-specific info on compiling SDL under Windows is available at
 
 
 
: http://www.libsdl.org/extras/win32/mingw32/README.txt
 
 
 
If you are having trouble with a message like 'no acceptable ld found in $PATH' try 'export LD=/c/gxx-2.95.2/bin/ld.exe' (or wherever you have the exe; GCC 2.95 in this case).
 
 
 
Also, if you have trouble getting ddraw (DirectDraw) working in DOSBox, see this post on the DOSBox forum for a possible fix:
 
 
 
: http://vogons.zetafleet.com/viewtopic.php?p=48050&highlight=#48050
 
 
 
==== 4b. SDL-net (optional) ====
 
 
 
If you want to benefit from DOSBox's Modem-Emulation or IPX-Support, you'll also need the SDL-net library, which can be found at
 
 
 
: http://www.libsdl.org/projects/SDL_net/
 
 
 
Download, extract, and compile as you did with SDL.
 
 
 
If you skipped building your own SDL.dll, you can use the one included with the latest official release of DOSBox or you can get a SDL_net win32 binary (.DLL) release on the SDL web site at the URL above.
 
 
 
=== 5. Compiling DOSBox ===
 
 
 
After compiling you'll need to adjust the PATH variable to point at the directory where the freshly built SDL-Library can be found.
 
 
 
''Note: if you want to use SDL-net, do the same with that library.''
 
 
 
Then, change to the directory where you extracted the DOSBox-Source and type
 
 
 
./autogen.sh
 
./configure
 
make
 
 
 
to compile DOSBox. If everything worked, you should have a <tt>DOSBOX.EXE</tt> in the <tt>./src</tt> - directory.
 
 
 
=== 6. Running ===
 
 
 
The easiest way to run the new executable is to copy it (and your fresh <tt>SDL.dll</tt> ''and maybe even the SDL_net.dll'') to the installation-directory of a non-SVN-version of DOSBox. That way, you have the needed directory structure and configuration files.
 
 
 
=== Example for Building DOSBox 0.71 on OpenSUSE 10.2 Linux ===
 
 
 
-Remove the existing DOSBox version if you have it.
 
 
 
-Obtain and extract the DOSBox source code.
 
 
 
-SUSE linux 10.2 already has SDL and alsa installed, but you need to install the SDL-devel package and alsa-devel package (for header files and libs).
 
 
 
-Obtain the SDL_Sound src from http://icculus.org/SDL_sound/downloads.  Extract the source somewhere.
 
Run configure --with-sdl-prefix=/usr/lib64 --with-sdl-exec-prefix=/usr
 
make
 
make install (need to be root)
 
 
 
-OK, now you have everything you need to compile DOSBox.  cd to your DOSBox directory, then run this at the shell:
 
export CPPFLAGS="-I/usr/local/include/SDL"
 
export LDFLAGS="-L/usr/local/lib"
 
configure --with-sdl-prefix=/usr/lib64 --with-sdl-exec-prefix=/usr --with-alsa-prefix=/usr/lib64
 
    --with-alsa-inc-prefix=/usr/include/alsa
 
make
 
make install (need to be root).
 
 
 
-The reason for the shell variables is that it seemed to be the only way configure could find the files it needed.  There aren't any config options to find the SDL_sound library, and I tried giving it -libdir= and -includedir=, but that didn't work.
 

Revision as of 23:41, 21 October 2014

Building your own version of DOSBox

MinGW is the development environment that this page will show you how to use, an alternative is to use Microsoft Visual Studio

This page will guide you through setting up MinGW to compile a current (SVN/CSV) version of DOSBox. Because of updates to compilers and libraries, this guide will not work with the 0.74 (the last official release, which is currently over 4 years old) source files.

Installing MinGW

  • Download mingw-get-setup.exe from http://sourceforge.net/projects/mingw/
  • Run the installer, choosing the defaults
  • Once the MinGW Installation Manager application starts, select
    • mingw-developer-toolkit (msys-base should be automatically added)
    • mingw32-base
    • mingw32-gcc-g++
  • On the installation menu, apply changes, and confirm that you want to apply the changes

The installation manager is going to download a bunch of files, and at the end, start installing them. Once this is done, you can close the dialog box as well as the installation manager.

Well done, MinGW is now installed! Let's start it up.

  • Browse to C:\MinGW\msys\1.0
  • Run MSYS.BAT

This will start up a DOS prompt like screen, lets mount the base path

 mount 'c:\MinGW' /mingw

You have now completed this section, lets move on to adding the SDL libraries to MinGW.

Adding the SDL libraries to MinGW

  • Download the pre compiled SDL development libraries from here http://www.libsdl.org/release/SDL-devel-1.2.15-mingw32.tar.gz
  • Copy the downloaded file to your MSYS home folder, it's going to be something like C:\MinGW\msys\1.0\home\Administrator
  • Switch back to the MSYS command prompt we started earlier
  • Lets extract the downloaded files
 tar xvf SDL-devel-1.2.15-mingw32.tar.gz
  • And now add the files to MinGW
 cd SDL-1.2.15
 make native
 cd ..

Cool, the SDL libraries have been added to MinGW, onto the next section.

Adding Direct Draw support to DOSBox (Optional)

If you want to give DOSBox the option to use the DDRAW output option, then we need to add a couple of extra libraries to MinGW

 tar xvf directx-devel.tar.gz -C /mingw

Adding SDL_net libraries to MinGW (Optional)

SDL_net gives DOSBox networking support, if you aren't going to be using DOSBox for multi player games, then you can probably skip this step.

 tar xvf SDL_net-1.2.8.tar.gz
  • Lets configure the libraries
 cd SDL_net-1.2.8
 ./configure prefix=/usr
  • And now compile them
 make
  • And then install them (copy the files)
 make install
 cd ..

Compiling DOSBox

 tar xvf dosboxsvn.tgz
  • Let's configure it
 cd dosbox
 ./autogen.sh
 ./configure LDFLAGS="-static-libgcc -static-libstdc++ -s"
  • And now for compiling DOSBox
 make
  • The last step is to gather all the files together in a folder
    • Create a folder with a name of your choosing
    • Copy the dosbox.exe file located under the dosbox\src folder, e.g. C:\MinGW\msys\1.0\home\Administrator\dosbox\src to the folder you created
    • Copy the SDL.dll file located under SDL-1.2.15\bin, e.g. C:\MinGW\msys\1.0\home\Administrator\SDL-1.2.15\bin to the folder you created
    • Optionally, copy the SDL_net.dll file located under SDL_net-1.2.8\.libs, e.g. C:\MinGW\msys\1.0\home\Administrator\SDL_net-1.2.8\.libs to the folder you created

Start up DOSBox, and see if it works.