Visual Studio Help - "Projects"
Table of Contents
For most programming with Visual Studio you will want to create and use
"projects". Projects are the way that Visual Studio organizes and
maintains the various files used for a program. Some of these files are the files
that you create for your C code. Other files include the "object" files
created by the compiler when you code is compiled, the "executable" file (*.exe)
that Visual Studio creates by linking your compiled code with other code, libraries, etc.
that are needed to run your program, and miscellaneous files that are used by Visual
Studio to organize and keep track of the status of your project.
To create a new project:
- Go to the File menu and choose New. The
"New" dialog box should be displayed.
- The "New" dialog box should have four tabs (Files, Projects,
Workspaces, Other Documents) located near the top
of the box. Choose the Projects tab. A listing of the types
of projects that can be created should then appear.
- Click on Win32 Console Application in the list of projects.
- Enter a name for the project in the space labeled Project Name at the
right of the dialog box.
- Choose a directory for the project in the space labeled Location at the
right of the dialog box.
- Once you have entered the name and directory for the file, click on the OK
button.
- Once you have clicked on the OK button the dialog box should display as set of choices
for the type of project or application. Choose "An empty project"
by clicking on the button next to this choice.
- Once you have chosen the type of project, click on the Finish button.
A dialog box will then appear telling you that an empty console application has
been created (with no C code files - you will need to create these next).
- Click on the OK button to dismiss the dialog box with the new project information.
You are now ready to start entering your C program code.
Before creating and adding files to a project be sure you have created a project
and the project is open. If the project is not open, open
the project first.
To begin adding files to a project:
- Go to the File menu and choose New. The
"New" dialog box should be displayed.
- The "New" dialog box should have four tabs (Files, Projects,
Workspaces, Other Documents) located near the top
of the box. Choose the Files tab. A listing of the types of
projects that can be created should then appear.
- Click on C++ source file in the list of file types that can be created.
- Make sure the Add to project check box is checked and the name of your
project appears in the box immediately below where Add to project
appears.
- Type a name for your file in the box labeled File name. Be sure
to use the extension ".c" for your file name, e. g. "myfile.c".
If you omit the extension, the file will be created as a C++ file, which could
cause some problems later.
- Click on the OK button once you have entered the necessary information
to create the new file. The new file should then be opened and displayed in the
Visual Studio window for you to start tying information.
- Be sure to save the file (using the Save in the File
menu) frequently and when you have finished entering information.Click on Win32
Console Application in the list of projects.
Before you can run a program you must have created a project and added files to
the project. To compile, link and run, i. e. to "build" you program first
be sure the project is open.
To "build" a project:
Compiling files:
Although we can just begin by building a project in one operation, we will
be gin by first compiling the individual files. During compilation Visual Studio
will check for errors and if none are detected, intermediate (object code) files will be
created.
- To compile a file, first make sure the file is open
- If more than one file is open, make sure the file that you want to compile is displayed
the frontmost window. If the window is not the frontm,ost window, you can move i tot
the front by clicking anywhere in teh window or by choosing teh window in the Window
menu where all open windows (files) will be listed (see teh end of teh dropdown Window
menu.
- To compile a file choose Compile filename1
from the Build menu - filename1 should be the
name of the file that you want to compile (frontmost open window).
- If there are errors in the file (C computer code) the errors should be displayed in a
window at the bottom of your screen. You should correc the errors and compile the
file again. Repeat this process of compilation and error correction until your file
has compiled successfully.
- Compile teh other files in your project, by opening each file, displaying it in the
frontmost the frontmost window and then choosing Compile from teh Build
menu.
- Once all files have been compiled succesfully you are ready to link your compiled code
with other code ("libraries") to build an executable program.
Linking ("building") the program:
- To build your program and create teh executable file choose Build My
Project.exe from the Build menu - "My
Project" represents teh name you chose for your project and the
extension ".exe" is used to designate that the file being
created will be an executable file. If you have not already compiled teh files in
your project, they files will be compiled. Your compiled files will then be linked
with the program libraries to form your executable program.
Running your program:
- To run your program select Execute My Project.exe
from the Build menu - "My Project"
represents the name you chose for your project.
Once you have created a project you can open it again later as follows:
- Go to the File menu and choose Open Workspace. A
standard Windows dialog box for opening files should be displayed.
- Choose the project you have previously created. The project should have the name
you gave it with the filename extension "dsw". Thus, if
you gave your project the name "My Project", it should appear with the file name
My Project.dsw.
- Click on the OK button to dismiss the dialog once you have entered the project name.
You should then be able to continue working on the project where you left off.
Wright | CE311K
| Civil Engineering | UT Austin