Click to See Complete Forum and Search --> : How to compile a C++ file in Visual Studio.Net?


ZhiYi
April 9th, 2005, 02:53 PM
Hello,

I have installed Visual Studio.Net 2003 on my PC. I created a new C++ file through File->New->File->C++ file. I typed some code but could not compile or build the program. There is no compile button or menu option in the IDE.

Adding the build toolbar buttons to the toolbar was futile because they are blanked out. I read a Visual C#.net book (could not find a Visual C++.net book) and the book said that executing the code is done by clicking on the 'play' button (a button resembling the play button on a video player). I tried it but the 'play' button was also blanked out.

So,how do I compile a C++ file in VC++.net? I used visual C++ 6. Compiling and building was very straight foward. There are buttons and menu options for it and they are clickable.

Thanks

Arjay
April 9th, 2005, 06:19 PM
You need to create a C++ project in order to compile the file. It's actually quite simple.

Here's what to do:

1) Click on the "File\New\Project..." menu item to open the "New Project" dialog.
2) In the "Project Types" tree control, select "Visual C++ Projects\Win32"
3) In the "Templates" list control, select "Win32 Console Project".
4) Enter the project name in "Name:".
5) Hit Okay
6) Click the "Finish" button when the "Win32 Application Wizard" dialog opens

You should end up with the following in <projectName>.cpp:



// projectnamecpp : Defines the entry point for the console application.
//
#include "stdafx.h"

int _tmain(int argc, _TCHAR* argv[])
{
return 0;
}


From there you can either remove the above file and add your file to the project, or copy over the contents of your file.

Arjay