Getting error messages when you attempt to show off your cool
C++ program on your friend's computer? The information in this
document explains how you can deploy your masterpiece on
any modern Microsoft Windows machine without too much work.
Look in the folder where your Visual Studio program stuff
installed. On my computer I chose the default location:
C:\Program Files\Microsoft Visual Studio 9.0
Dig a little deeper, into the folder:
C:\Program Files\Microsoft Visual Studio 9.0\VC\redist\x86\Microsoft.VC90.CRT
In this folder you'll find four files:
Microsoft.VC90.CRT.manifest
msvcm90.dll
msvcp90.dll
msvcr90.dll
Say the Win32 console application you compiled and wish to
distribute is named myprog.exe. Make a new folder somewhere
and copy your executable and those four files above into the
new folder. Your folder should contain:
myprog.exe
Microsoft.VC90.CRT.manifest
msvcm90.dll
msvcp90.dll
msvcr90.dll
You can now copy this folder to any recent Windows machine, open the
folder, and double click on myprog.exe. It will launch in a command
window and run to completion. Note: The Visual Studio console environment
conveniently adds the "Press any key to continue..." prompt that allows
you to press a key to close the window. In the normal Windows environment
the window closes immediately when the program is done. You would need to
add a prompt at the end of your main function to achieve the same effect.
If you are running from a CMD.EXE shell, the shell does not go away,
of course, when the program finishes.
I compiled a C++ program using Visual C++ on my laptop running Vista
Home Edition (the machine I use in class), copied the executable and
those files mentioned above onto a USB thumb drive, and ran the program
off the thumb drive without a problem on a really old Windows XP laptop
without Visual Studio installed. It ran without a problem.
To run a graphical program based on the GLUT library (like the Visual
Geometry program) on a machine without Visual Studio, it is only slightly
more work:
1. Make the new folder as before.
2. Copy the above mentioned Microsoft.VC90.CRT.manifest,
msvcm90.dll, msvcp90.dll, and msvcr90.dll files into
the folder.
3. Copy the glut32.dll file into the folder.
4. Open the Microsoft.VC90.CRT.manifest file with a
text editor and add
to the end of the line containing
the other dll files, as in
5. Copy your compiled executable (like visual_geom.exe) into
the folder.
6. Copy the entire folder to the target computer, open the
folder, and double click the executable program. A command
window will open (because it's a Win32 console application),
and then the graphics window will open and you can interact
with it.
The good news is that this work can be done once and then reused.
Once you've created the new folder with the dlls and the hacked
manifest file (for GLUT apps), tuck it away in a safe
place. When you are ready to deploy one of your graphical
programs, simply make a copy of that standard folder, drop
your executable into the folder, and it should be ready to go.
The user-friendly way to deploy your program is to create an installer
program named setup.exe that contains all the necessary files (the dlls,
the manifest file, and your executable) packed within itself. When run,
the installer would unpack itself and install all the appropriate files
in a user selected location.
(Rick Halterman 2008-12-03)