Docsity

Creating and Configuring Visual C++ Projects in Visual Studio 2005 - Prof. James Fawcett, Study notes of Engineering

Toggle sidebar
bg1
Running Visual C++ (Visual Studio 2005) Revised
1/14/2006
Jim Fawcett, CSE687 – Object Oriented Design, Spring 2006
1. Creating a new empty solution (Figure 1.):
Click File\New\Project (ctrl+shift+N) to get a tabbed dialog box with project tab selected.
Enter a solution location by typing or browsing (if the path you type does not exist it will be
created).
Select Other Project Types/Visual Studio Solutions and click on Blank Solution
Enter a name for your project (will reside in a subdirectory in your workspace by default –
change by editing the location).
Click on OK – this creates a directory holding a solution file, intellisense database file, and a
user options file
2. Creating a new project (Figures 2. and 3.)
Right click on Solution in Solution Explorer and select Add/New Project
In the resulting dialog select Visual C++/Win32 and click on Win32 Projects and click
on Win32 Project
Enter a project name in the first text box and click OK
In the resulting dialog, click on Application Settings and, in the resulting dialog, click
on either Windows Application (WinForm project) or Console Application and also
select empty project.
Click on OK – this creates a project subdirectory in the solution directory, and places
a project file in that directory.
You can create as many projects as you wish in a given solution. Sometimes you
may wish to create two or more projects with the same files but with different
properties. Multiple projects let you work on a single module, or the entire program,
simply by switching between projects.
It is a very good idea to make a project for each of your modules. You implement a
solution by adding the first module’s project, building, and testing with the module’s
test stub. Then add another project, and add existing source code from the first
project (see item 4., below) if the new module depends on the first module’s services.
Now you will set this module’s properties to compile the second project’s test stub,
not the first (see Step 8, and Figure 7.). Continue this way until the solution is
complete.
3. Adding a new source code file (Figures 4. and 5.):
Right click on project and select Add/Add New Item
Select UI to add a form or Code to add a header or implementation file.
Select C++ file or header file, enter name, and click OK
Now you are ready to enter code
Note: adding a new file creates a blank file in the project directory
4. Adding an existing file to the project:
Right click on project and select Add/Add Existing Item
Browse through directories until you find the file you want.
Select it and click OK
Note: adding an existing file to a project does not copy or move any file. It simply adds the
path to the selected file into the project settings. Be aware that if you change this added
existing file in the IDE editor, it will change the original back in its source folder. This is not the
way C# works, and is probably not what you want.
To avoid this you can make a copy, using Windows Explorer, and add the copy to the
project directory.
That, of course, means that you now have two versions of the file. Be careful!
5. Compiling and Linking:
Click Build\Build or right click on project or solution and select build or rebuild
By default, if you select build it will build all projects in the solution. If you select Project
Only/Build, you will build just the selected project.
Warnings and errors are shown in the bottom window. Fix these and rebuild.
Double click on warnings and errors to go to the problem location in source code
6. Running the result of a build:
Click Debug\Start without Debugging or depress Ctrl F5
I add the Start without Debugging symbol to my toolbar with Tools\Customize\Debug using
drag and drop. A click on that will start an execution
7. Enter command line parameters before running (Figure 6.):
Click Project\Settings to get a tabbed dialog box.
Click on Debug tab and enter Program arguments for the command line
1
pf3
pf4
pf5
pf8
pf9
pfa

Partial preview of the text

Download Creating and Configuring Visual C++ Projects in Visual Studio 2005 - Prof. James Fawcett and more Study notes Engineering in PDF only on Docsity!

Running Visual C++ (Visual Studio 2005) Revised

Jim Fawcett, CSE687 – Object Oriented Design, Spring 2006

1. Creating a new empty solution (Figure 1.):

 Click File\New\Project (ctrl+shift+N) to get a tabbed dialog box with project tab selected.  Enter a solution location by typing or browsing (if the path you type does not exist it will be created).  Select Other Project Types/Visual Studio Solutions and click on Blank Solution  Enter a name for your project (will reside in a subdirectory in your workspace by default – change by editing the location).  Click on OK – this creates a directory holding a solution file, intellisense database file, and a user options file

2. Creating a new project (Figures 2. and 3.)

 Right click on Solution in Solution Explorer and select Add/New Project

 In the resulting dialog select Visual C++/Win32 and click on Win32 Projects and click

on Win32 Project

 Enter a project name in the first text box and click OK

 In the resulting dialog, click on Application Settings and, in the resulting dialog, click

on either Windows Application (WinForm project) or Console Application and also

select empty project.

 Click on OK – this creates a project subdirectory in the solution directory, and places

a project file in that directory.

 You can create as many projects as you wish in a given solution. Sometimes you

may wish to create two or more projects with the same files but with different

properties. Multiple projects let you work on a single module, or the entire program,

simply by switching between projects.

 It is a very good idea to make a project for each of your modules. You implement a

solution by adding the first module’s project, building, and testing with the module’s

test stub. Then add another project, and add existing source code from the first

project (see item 4., below) if the new module depends on the first module’s services.

Now you will set this module’s properties to compile the second project’s test stub,

not the first (see Step 8, and Figure 7.). Continue this way until the solution is

complete.

3. Adding a new source code file (Figures 4. and 5.):

 Right click on project and select Add/Add New Item  Select UI to add a form or Code to add a header or implementation file.

 Select C++ file or header file, enter name, and click OK

 Now you are ready to enter code  Note: adding a new file creates a blank file in the project directory

4. Adding an existing file to the project:

 Right click on project and select Add/Add Existing Item  Browse through directories until you find the file you want.  Select it and click OK  Note: adding an existing file to a project does not copy or move any file. It simply adds the path to the selected file into the project settings. Be aware that if you change this added existing file in the IDE editor, it will change the original back in its source folder. This is not the way C# works, and is probably not what you want.  To avoid this you can make a copy, using Windows Explorer, and add the copy to the project directory.  That, of course, means that you now have two versions of the file. Be careful!

5. Compiling and Linking:

 Click Build\Build or right click on project or solution and select build or rebuild

 By default, if you select build it will build all projects in the solution. If you select Project Only/Build, you will build just the selected project.  Warnings and errors are shown in the bottom window. Fix these and rebuild.  Double click on warnings and errors to go to the problem location in source code

6. Running the result of a build:

 Click Debug\Start without Debugging or depress Ctrl F

 I add the Start without Debugging symbol to my toolbar with Tools\Customize\Debug using

drag and drop. A click on that will start an execution

7. Enter command line parameters before running (Figure 6.):

 Click Project\Settings to get a tabbed dialog box.  Click on Debug tab and enter Program arguments for the command line

 Click OK

Figure 1. – Add Blank Solution

Figure 2. – Add a Win32 Project Figure 3. – Select Application Settings

Figure 6. – Command Line Parameters

Figure 7. – Add Preprocessor Definitions

Command Line

arguments

Test Stub Definition

Figure 10. – Tabs and Spaces

Select a tab size to suit your preferences for indenting sizes. It is a good idea to select

Insert spaces. The reason for that is, almost every printer on earth will, by default, print

tabs as 8 spaces, which will make your listings look peculiar.

Note that, if you print from the idea, the IDE commands the printer to use correct spacing,

but if you print with any other program, or from the command line, you will get the printer

defaults.