Compiling With Visual C++

Building a Multiple-File Project -- Console Program


Creating a New Project

  1. Open Visual C++ and select New from the File menu.
  2. Under the Projects tab, select "Win32 Console Application"
  3. Type a name for the project in the "Project name" box, select a directory to save the project in ("Location" box), and click "OK".  (Make sure the "Create New Workspace" button is checked).
  4. In the next dialog box, titled "Win32 Console Application - Step 1 of 1", select "An empty project" and click "Finish", then click "OK" on the next pop-up box.

Creating a New Code File in the Project

  1. Once the project is open, to create a new code file as part of the open project, select New from the File menu.
  2. Under the File tab, select either the "C/C++ Header File" (to create a new header file) or "C++ Source File" (to create a .cpp file).
  3. Make sure the "Add To Project" box is checked, and the project name shows up in the box just below.
  4. Type a filename in the "Filename" box, and select a directory to store it in, in the "Location" box.
  5. Click "OK"
  6. A blank page will come up in the text editor.  Type your code for the given file here.

Adding an Existing Code File to the Project

  1. In the open project, select Add To Project --> Files from the Project menu.
  2. Use the dialog box that comes up to locate and select the file(s) to add to the project, then click OK.
  3. You can select more than one file by holding down the "Ctrl" key and clicking on each file you want to add to the project.

Viewing the list of files that currently make up the project

  1. In the window on the left of the screen, there should be two tabs at the bottom:  "Class View" and "File View".  Click on the "File View" tab.
  2. Click the + symbols in the window to expand the information about the project.
  3. Under the project heading, there should be folders called "Source Files" and "Header Files".  All of your .cpp files should show up in the first of these.  The header files (the .h files) should show up in the latter.
  4. Make sure that all files needed to make up an executable have been added to the project (and only once each) before trying to build the project.

Building the Project