Separate Compilation using VC++ (5.0 or newer)
Basically there are two ways to compile (i.e., build a
project) multiple files using VC++: either you already have files
in some directory (or they might have been copied from somewhere
else) and create a project, or you create a project first and
type in the files.
- Case 1: Source files exit already under
some directory
- Create/type source files and save them under some
directory. Say you created "class1.h"
(header file), "class1.cpp"
(implementation file) and "app1.cpp"
(application file) under a directory
c:\courses\310\assign1.
- Create a new project by selecting from the top
menu-bar: File, New.
In the pop-up window ("New"), select "Projects"
tab (which may be selected by default).
Then
- Select "Win32 console
application" on the left-hand side
box,
- Clear the entry in the "Location"
box on the right-hand side, and type in the path to the directory
"C:\courses\310"
(with no " ". Be sure
NOT TO include the last subdirectory "assign1").
- Type in the directory name "assign1" (with no
" ") under the "Project
name" box.
At this point, you see
"assign1" is automatically concatenated
with the path name in "Location".

Hit OK.
- From the top menu-bar, select Project,
Add to Project and Files.
In the pop-up window, select .cpp files
ONLY (in the example above,
"class1.cpp" and
"my_app.cpp"). You can add one file at
a time by repeating this step, or select multiple
files by holding down the control key and
clicking on the files.

Hit OK.
- Build the project by pressing the Build button or
selecting from the top menu-bar Build
and Build assign1.exe.
- Run the project.
- Case 2: Create a project first and add new files as you create them
- For VC++ 6 users, this procedure is explained in the document "Using
VC++" under "Project
Compilation".
- For .NET and Visual Studio 2003 users, this procedure is the
same as before -- create a project and add new files.
However, when you create a new .h (header) file, be sure to select
"Header File (.h)" icon.
