C++ Workshop - IDE Installation & Configuration

Started by
4 comments, last by FireNet 17 years, 9 months ago

Creating and Building a Project w/ VC++ .NET 2005

The instructions for creating a project/file in the book on pages 19-20 are for Visual C++ 6. Visual C++ .NET 2005 is actually version 8. The correct approach for .NET 2005 is: Step 1: Create an empty project
  1. File->New->Project
  2. Select 'Win32' from Project types
  3. Select 'Win32 Console Application' from the Templates
  4. Type the name of the project and the location in the edit box near the bottom.
  5. Click OK
  6. When the dialog box appears click on "Application Settings" on the left
  7. Click "Empty Project" under Additional options.
  8. Click Finish
Step 2: Add files to your project
  1. Right click on your project in the Solution Explorer
  2. Add->New Item
  3. Click Code in the Categories List
  4. Select either C++ File or Header File as appropriate to the task
  5. Type the name of the file in the edit box near the bottom.
  6. Click Add
Building your executable For solutions which only have a single project, Build Solution will do the same as "Build <projName>". Once you have solutions which are containers for multiple projects, you will need to choose either to build individual projects, or the whole solution. The tasks we will attempt in this workshop will most likely require only a single project. As such, "Build Solution" should work just fine.
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
Advertisement
[edit: stupid mistakes]

Same as Fruny, but for VS .NET 2002 to 2003

Creating and Building a Project w/ Visual Studio .NET 2003


The instructions for creating a project/file in the book on pages 19-20 are for Visual C++ 6. Visual Studio .NET 2003 is actually version 7.1 (VS .NET 2002 is version 7).

The correct approach for .NET 2003 is:

Step 1: Create an empty project
  1. File->New->Project
  2. Open the 'Visual C++ Projects' branch in the Project types panel
  3. Select 'Win32' from Project types
  4. Select 'Win32 Console Application' from the Templates
  5. Type the name of the project and the location in the edit box near the bottom.
  6. Click OK
  7. When the dialog box appears click on "Application Settings" on the left
  8. Select 'Console application' under Application type
  9. Click "Empty Project" under Additional options.
  10. Click Finish
Step 2: Add files to your project
  1. Right click on your project in the Solution Explorer
  2. Add->New Item
  3. Click Code in the Categories List
  4. Select either C++ File or Header File as appropriate to the task
  5. Type the name of the file in the edit box near the bottom.
  6. Click Add
Building your executable
For solutions which only have a single project, Build Solution will do the same as "Build <projName>". Once you have solutions which are containers for multiple projects, you will need to choose either to build individual projects, or the whole solution.

The tasks we will attempt in this workshop will most likely require only a single project. As such, "Build Solution" should work just fine.

About "precompiled headers"
They are rather annoying when you are a beginner - mostly because most of the time, you forget to add this stupid and quite obscure #include "stdafx.h" at the beginning of the source code file.

If you decide to go without them:
  1. in the Project menu, chose the properties menu option (or, in the solution explorer, right click your project and select properties)
  2. In the Configuration drop down combobox, select All Configurations
  3. in the left panel, select the Configuration Properties / C++ / Precompiled Headers branch
  4. in the right panel, on the Create/Use Precompiled Headers, select the Not Using Precompiled Headers option.


[Edited by - Emmanuel Deloget on June 15, 2006 5:46:59 AM]
I have been using Microsoft Visual C++ 2005 Express Edition since the beginning of this workshop and didnt have any problems untill today. When I run ( debug ) projects that I had build prior to today, they execute just fine. Tought I cant debug any new project. I can write source code, compile and link them but cant debug them. Each time I ctrl+f5 this error message pops up :
Quote: "This application has failed to start because MSVCR80D.dll was not found. Re-installing the application may fix the problem."


Unfortunatly, re-installing didnt fix anything. So I googled the name of the missing file, MSVCR80D.dll. I found a remedy on a forum which goes like this :
Quote: I have changed the "Properties Pages->Conf. Properties ->Linker -> Debugging-> Generate Map File" switch to Yes. Now the error does not occour and the app runs well. I do not know why. The map file dipicts sm'thing like this
Now, this did indeed fix the error but, I'm wondering if this change wont mess my programs. What is it doing exactly ? Also, I have to switch Map File to Yes on every new project I start. Do you have any other fix to this problem ?

Thank you.
Sorry, I can't really help you here. As a matter of fact, I recently started having the same problem. I haven't gotten around reinstalling VS yet.

Edit: Deleting the manifest files from the output directory as suggested here, and then rebuilding the project appears to work.

Edit 2: I spoke too fast. It is broken again.
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
Indeed, it works. So, you can either
Quote: Delete the manifest.res file from the output directory, and then rebuild the project.

or
Quote: Change the "Properties Pages->Conf. Properties ->Linker -> Debugging-> Generate Map File" to Yes.


Let us know if you find a more "general" solution, One that doesnt apply to a single project.

EDIT : Fruny your solution does work. Build your project, go in its folder, then find the file C:\...\Visual C++\Nameofproject\Nameofproject\Debug\Nameofproject.exe.embed.manifest.res . Delete it, build again and it will run.

Creating and Building a Project w/ Dev-C++ v 4.9.x.x

Dev-C++ is a free IDE for the mingw compiler. It is a much smaller download and should work almost the same. I would like to include it here cause once upon a time I had a tiny bandwidth and had nothing but the free compilers on the net.


An approach for Dev-C++ is:

Step 1: Create an empty project
  1. File->New->Project
  2. Select 'Basic' from Project types
  3. Select 'Console Application' from the Templates
  4. Type the name of the project and the location in the edit box near the bottom.
  5. Click OK
  6. Save the project at some appropriate location

Step 2: Add files to your project
  1. Right click on your project in the Project Tab (on the left)
  2. Add->New File
  3. An untitled file with appear in the project
  4. Save it as a .h or .cpp file

Building your executable
  1. To compile and run: Execute->Compile & Run
  2. Or Press F9


Additional: Importing Visual C++ Projects (.dsp)
Yup, you can do this ;)

  1. File->Import->Import MS Visual C++ Project
  2. Choose an VC++ project file (Browse)
  3. Then you can choose a configuration and the path to the new Dev-C++ project (Defaults available)



Note: This may not work for each and every project ;)
______________________________________________________________________________________________________
[AirBash.com]

This topic is closed to new replies.

Advertisement