pebbles image

Visual C++ 2010 - Creating a new Win32 Console Application:

This information is for Visual C++ 2010 (Express). Earlier versions of Visual C++ will be similar, but with slight differences in the locations of various menu options. Let us assume you have a directory "MyProject", containing the source code (.c, .cpp, or .h) files for your project.

  • Launch Microsoft Visual C++
  • 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".
    • 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.vcproj and/or MyProject.vcxproj (records 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" section (probably on the left) and click "MyProject".
    • Select "Project → Add Existing Item..." (Alternatively, you can right-click "MyProject" in the Solution Explorer window and select "Add → Existing Item" from here.
    • 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 "Add". (In the Solution Explorer section, you should now see your .h files listed under "Header Files" and your .c and .cpp files listed under "Source Files".)
    • To view/edit a file, double-click on it.
  • If you need to set additional configuration options (e.g., directories to search for include files or .lib files).
    • Select "Project → MyProject properties...".
    • This will bring up a window with lots of sections for various options.
    • For example, under "Configuration Properties":
      • If you want to select directories to search for header files select "C/C++ → General" and add these in "Additional Include Directories". (If you installed glut.h in the proper directory, you should not need to change this.)
      • If you want to select directories to search for library files select "Linker → General" and add these in "Additional Library Directories".
      • If you want to debug your program, you may want to select "Debugging" add set any command-line arguments or alter the working directory. These will be passed in to your main program using argc and argv.
  • To compile:
    • Select "Debug → Build Solution" (or hit F7). (On other Visual C++ versions this may be under the "Build" menu.)
    • Note that the compiler allows for two common compiler configurations.
      • "Debug" adds additional debugging information to the compiled code.
      • "Release" performs additional code optimization.
  • To run (in debug mode):
    • Select "Debug → Start Debugging" (or hit F5).
    • 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").
  • 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 427 Home   -

Web Accessibility