Building MAME using Microsoft Visual Studio compilers: Difference between revisions
From MAMEDEV Wiki
mNo edit summary |
m (fix link markup) |
||
Line 5: | Line 5: | ||
Here's how to make it work: | Here's how to make it work: | ||
# You must already have an environment that can build MAME using the MinGW tools. Although you won't be using gcc to compile, you will be using several of the other tools included in the standard MAME | # You must already have an environment that can build MAME using the MinGW tools. Although you won't be using gcc to compile, you will be using several of the other tools included in the standard MAME [http://mamedev.org/tools/ MinGW Development Environment] | ||
# From the command prompt, you need to run the batch file that was installed with Visual Studio which configures the executable, include, and library paths. | # From the command prompt, you need to run the batch file that was installed with Visual Studio which configures the executable, include, and library paths. | ||
#* For Visual Studio .NET 2003, the command is: (can't remember) | #* For Visual Studio .NET 2003, the command is: (can't remember) |
Revision as of 13:37, 9 July 2008
By default, MAME is configured via the makefile to build using the MinGW gcc compiler. Although this is a nice cross-platform solution, debugging binaries built this way leaves a lot to be desired.
If you own a copy of Visual Studio .NET 2003 or Visual Studio 2005, you can configure MAME to build using those tools instead. Once you have done that, you can debug problems in MAME using the Visual Studio debugger, which is a huge step up from gdb.
Here's how to make it work:
- You must already have an environment that can build MAME using the MinGW tools. Although you won't be using gcc to compile, you will be using several of the other tools included in the standard MAME MinGW Development Environment
- From the command prompt, you need to run the batch file that was installed with Visual Studio which configures the executable, include, and library paths.
- For Visual Studio .NET 2003, the command is: (can't remember)
- For Visual Studio 2005, the command is:
"\Program Files\Microsoft Visual Studio 8\VC\vcvarsall.bat" x86
- (To build a 64-bit version, change the
x86
toamd64
)
- (To build a 64-bit version, change the
- Switch to the directory where the root MAME makefile lives.
- Delete any object files from previous builds using gcc:
rd /s obj
- Once you've done that, simply run:
mingw32-make MSVC_BUILD=1 DEBUG=1 SYMBOLS=1
and wait for it to complete (I suggest building with DEBUG=1 as that also disables optimizations and makes debugging much easier).- (To build a 64-bit version, add
PTR64=1
to the end of your command line.)
- (To build a 64-bit version, add
At this point, you should now have a mamed.exe that was built using Visual Studio tools. To debug it is very easy.
- Open up Visual Studio.
- From the File menu choose "Open Project..."
- Select mamed.exe (you may need to adjust the file filters to show .exe files).
- To configure command line parameters, right click on the mamed.exe item in the Solution Explorer window and choose "Properties". In that window you can specify the "Command Arguments" which would be the command line parameters you want.
- Set some breakpoints if you want, and hit "Go" (F5), or else single step into main by hitting "Step Into" (F11).
- When you're done, Visual Studio will ask if you want to save a solution file (.sln); I usually say "yes", because then it will remember your last session parameters for the next time you want to debug MAME, and the solution will show up in the recent projects list.
Back to How MAME Works