Building DOSBox with Visual Studio

From DOSBoxWiki
Revision as of 00:35, 14 July 2018 by Rainwarrior (talk | contribs) (→‎Build DOSBox: formatting)
Jump to navigationJump to search

While the official Windows build environment for DOSBox is MinGW, it may also be built in Visual Studio for users more comfortable with this.

Get Visual Studio

Free versions of Visual Studio are available at:

The free version of Visual Studio 2017 is called the "Community" edition. Prior to this (VS2005-2015) free versions were called the "Express" edition.

Some older versions are available at:

When installing Visual Studio, there may be tools for multiple languages available (C++, C#, Visual Basic .NET, Java, etc.) but only the C++ tools are necessary for DOSBox.

Get Libraries

  • Optional for compressed audio disc images:
  • Optional for DOS debugging tools:

Prepare Libraries


If using VS2013 or earlier, you can use the pre-built library in For VS2015 or later you will need to rebuild it from source (

  • Open SDL-1.2.15\VisualC\SDL.sln and allow Visual Studio to automatically convert the solution and project to the latest version.
  • Select the Release configuration and use the Build menu to build the solution.
  • The following 3 files should be built:
    • SDL-1.2.15\VisualC\Release\SDL.dll
    • SDL-1.2.15\VisualC\Release\SDL.lib
    • SDL-1.2.15\VisualC\SDLmain\Release\SDLmain.lib
  • The following folder also contains relevant include files for the library:
    • SDL-1.2.15\include
  • If you need more info on building SDL with VS, see: SDL-1.2.15\VisualC.html

zlib / libpng (optional)

Enables screenshot and video capture.

Because zlib is a dependency of libpng, a VS solution to build both at once is provided by the libpng package.

  • Unpack to create the folder: lpng1634
  • Unpack zlib-1.2.8.tar.gz to create an adjacent folder: zlib-1.2.8
  • Open lpng1634\projects\vstudio\zlib.props with a text editor.
    • Near the bottom of the file you will find <DisableSpecificWarnings>. Add ;5045 to the end of this list. (This disables a new spurious warning in VS2017.)
  • Open lpng1634\projects\vstudio\vstudio.sln and allow Visual Studio to automatically convert the solution and projects to the latest version.
  • Select the Release Library configuration.
  • Right click on the zlib project in the solution explorer and open its Properties.
    • From Configuration Properties > C/C++ > Preprocessor > Preprocessor Definitions remove Z_SOLO. (Currently causes video capture to fail and crash.)
    • Change Configuration Properties > C/C++ > Code Generation > Runtime Library to Multi-threaded DLL (/MD).
  • Right click on the zlib project and build it.
  • Now open the libpng project's properties.
    • Change Configuration Properties > C/C++ > Code Generation > Runtime Library to Multi-threaded DLL (/MD).
  • Build the libpng project.
  • The following libraries should now be built:
    • lpng1634\projects\vstudio\Release Library\zlib.lib
    • lpng1634\projects\vstudio\Release Library\libpng16.lib
  • Include folders:
    • lpng1634
    • zlib-1.2.8
  • For more libpng build information see: lpng1634\INSTALL

SDL_net (optional)

Enables networking.

You can use the pre-built libraries in

  • Library files:
    • SDL_net-1.2.8\lib\x86\SDL_net.dll
    • SDL_net-1.2.8\lib\x86\SDL_net.lib
  • Include folder:
    • SDL_net-1.2.8\include

SDL_sound (optional)

Enables the use of CD images with compressed audio.

  • Guide not yet written.

PDCurses (optional)

Enables a DOS debugger.

  • Guide not yet written.

Get DOSBox Source

Build DOSBox

  • After downloading the source code, open the Visual Studio solution: dosbox\visualc_net\dosbox.sln
  • Allow it to automatically convert to the latest version.
  • Right click the dosbox project in the Solution Explorer and open its Properties.
    • When editing the properties, edits will have to be made for each configuration you may want to build. In the top left there is an option for Debug, Release and All Configurations. The Release build is most commonly used, but All Configurations will let you conveniently edit both at once wherever the two configurations have the same options.
    • Click the drop down triangle on Configuration Properties > C/C++ > General > Additional Include Directories and edit this list. Add the appropriate include path for each library prepared above. Keep in mind that paths are relative to the dosbox\visualc_net folder.
    • Edit Configuration Properties > Linker > General > Additional Library Directories and add the path to each library (.lib) file prepared above.
    • Edit Configuration Properties > Linker > Input > Additional Dependencies to add or remove libraries. (You will have to select either the Debug or Release configuration for this, as the Debug build uses a different list of libraries than the Release.)
      • Remove zlib.lib and libpng.lib if not using these. Rename libpng.lib as libpng16.lib if you are using it.
      • Remove sdl_net.lib if not using it.
      • Add an entry for SDL_sound if using it.
      • Remove curses.lib if not using it.
  • Find dosbox\src\platform\visualc\config.h and open it (in the solution explorer it is under dosbox \ Source Files \ visualc).
    • C_SSHOT to 0 if not using zlib/libpng.
    • C_MODEM and C_IPX to 0 if not using SDL_net.
    • Add #define C_SDL_SOUND if using SDL_sound.
    • C_DEBUG to 1 if using the PDCurses.
  • After all of this is set up, you may build the dosbox project. Choose a Debug or Release configuration (recommend: Release) and use the build menu to build the solution. One of the following will be built:
    • dosbox\visualc_net\Release\dosbox.exe
    • dosbox\visualc_net\Debug\dosbox.exe
  • Finally, take the SDL.dll and SDL_net.dll files prepared above and place them in the same directory as dosbox.exe. It should now be ready to run.