Super Mario Bros image

Visual Studio 2010/11/12 - Creating a new Win32 Console Application:

This information is for Visual Studio with Visual C++ (2010, 2011, or 2012). Various versions of Visual Studio differ slightly in the locations and names of various menu options, but the principals are the same. Let us assume you have a directory "MyProject", containing the source code (.c, .cpp, or .h) files for your project.

  • Launch Microsoft Visual Studio
  • Select "File → New → Project..."
  • This will bring up a window "New Project".
    • Select "Win32 Console Application".
    • Under "Name", enter your project name (e.g., "MyProject").
    • Under "Location", click "Browse" and navigate to the directory containing your source files.
    • You can leave the box "Create a directory for solution" checked (it doesn't matter much).
    • Click "OK".
  • Next a window "Win32 Application Wizard" will come up.
    • Click the "Application Settings" button on the left.
    • Under "Application type" be sure that "Console application" is selected.
    • Under "Additional options" select "Empty project".
    • If there are other esoteric sounding options, you can un-select them. We want to produce a plain, vanilla program.
    • Click "Finish".
  • At this point, if you open a Windows Explorer window, you will see a new directory "MyProject in the directory with your source files. This is where Visual Studio stores all its configuration files. If you mess anything up, you can always go back and remove this directory and start over again. This important files are:
    • MyProject.sln (solution file).
    • MyProject.vcxproj (or depending on the version MyProject.vcproj) This file stores compiler options for the project.
    • There are a number of other files, but these the most important, since they are the only ones we need to compile your program submission.
  • Returning back to the Visual Studio main window, go to the "Solution Explorer" window (probably on the left) and right-click "MyProject" to obtain a drop-down menu.
    • Select "Add → Existing Item" (Depending on your version of Visual Studio, this option may be located elsewhere.)
    • This will bring up a window "Add Existing Item". Navigate up to the with your source files and (using control-click) select all your .cpp and .h source files.
    • Click the "Add" button at the bottom of the window. (In the Solution Explorer section, you should now see the names of your .h files now appear under "Header Files" and the names of your .c and/or .cpp files appear under "Source Files".)
    • To view/edit any of these files, double-click on its name in the Solution Explorer window.
  • If you might need to set additional configuration options for your project. To do this:
    • Go to the Solution Explorer window, right click on the name of your project, say "MyProject" to bring up the drop-down menu and select "Properties".
    • This will bring up a window with lots of sections for various options. on the left side of the window you will see property classes ("General", "Debugger", "C/C++", "Linker", etc.), and on the right you will see specific properties.
    • For OpenGL/GLUT applications, you may need to add the following options.
      • You may need to specify which directories are to searched for GLUT header files. By default, Visual Studio will search look in the same directory where "gl.h" and "glu.h" are stored, so if you put "glut.h" here as well, you should not need to modify this. If you stored the include file elsewhere,Select "Configuration Properties → C/C++ → General" and on the right locate "Additional Include Directories". Click on the box to edit its contents, and add the full directory path there.
      • If you want to select directories to search for library files select "Linker → General" and add these to "Additional Library Directories". (Again, if you stored "glut23.lib" in the same directory as "opengl32.lib" then this should not be necessary.)
      • When you run your program, you may need it to execute in a particular directory (e.g., where your input files are stored) or with particular command-line arguments. To do this, select "Debugging" modify the Command Arguments or Working Directory entries. Command-line arguments are passed in to your main program using argc and argv arguments in your main program.
  • To compile:
    • If you don't see the Build menu at the top (it comes between "Project" and "Debug"), select "Tools → Settings → Expert Settings..."
    • Select "Build → Build Solution" (or hit F7).
    • Note that the compiler allows for two common compiler configurations.
      • "Debug" adds additional debugging information to the compiled code.
      • "Release" performs additional code optimization.
    • If the compiler complains that it cannot find GLUT include files ("glut.h") check that it is placed in the proper directory. (See the entry above about "Additional Include Directories".)
    • If the linker complains of unresolved GLUT externals, such as "glutInit", check that "glut32.lib" is placed in the proper directory. (See the entry above about "Additional Library Directories".)
  • To run (in debug mode):
    • Select "Debug → Start Debugging" (or hit F5). If the loader complains about missing dll's, then check that you have placed glut32.dll in the proper directory.
    • You can also run your program from a standard command-prompt window (e.g., by selecting "Windows Icon → All Programs → Accessories → Command Prompt", navigating to the Debug or Release directory, and typing in "MyProject.exe").
    • If your program complains that it cannot find your input files, then see the entry above about "Working Directory".
  • To clean compilation files:
    • On some Visual C++ versions you can remove compilation files using "Build → Clean Solution". (This option does not seem to exist on Visual C++ 2010 Express.)
    • Before submitting, I would suggest deleting all the large binary files, such as "MyProject.exe", "MyProject.ncb", "MyProject.ilk" and "MyProject.pdb". These are quite large and are not needed to recompile your program.

-   CMSC 425 Home   -

Web Accessibility