RSS

Compiling a Native C++ Program from Command Line (C++)

25 Nov

1.Run Visual Studio 2008 Command Prompt window with Administrator privileges.
2.Set the following directory as the current directory at the command prompt: \Program Files\Microsoft Visual Studio <version>\VC.
3.In command prompt, type notepad sample.cpp and press Enter.

Click Yes when you are prompted to create a new file.
4. Type following code in notepad

#include <iostream>

int main()
{
std::cout << “This is a sample C++ program.” << std::endl;
return 0;
}

5.On the File menu, click Save. You have created a Visual C++ source file.

6.In command prompt, type cl /EHsc sample.cpp and press Enter. The /EHsc command-line option instructs the compiler to enable C++ exception handling

7.The cl.exe compiler generates an executable program sample.exe.The .obj file is an intermediate format file.

8.To run the sample.exe program, type simple and press Enter.

Advertisements
 
Leave a comment

Posted by on November 25, 2011 in C++

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: