Command Prompt

There was a tutorial I was following, describing how to write code in the Command Prompt, it directed me to change the directery I think from C/:windows32 to /Program Files/Microsoft Visual Studio 9.0/VC I could not figure out how to so I looked online and it gave me a coulple of clues LINK.EXE things of that nature I must have done something because now

C++ wont run the debugger with out binary code? It will build the program but? I really have no clue what I did

Can someone help please
Do you mean using the

 
system("");


commands?

Like for example

1
2
system("cd ..");
system("dir");


Will list the contents of the parent directory of where the cmd is run.

closed account (S6k9GNh0)
The above is generally a bad way to go. A much more secure and sure-fire way to go would be to use the WinAPI. However, you seem rather confused about the whole ordeal and it sounds like you either didn't read the tutorial correctly or it's just a confusing tutorial. If you wouldn't mind posting the tutorial so I could read what it meant or perhaps get a gist of your knowledge, I'd be able to help you more.
MSDN Library
Send Community Content Click to Rate and Give Feedback
Give feedback on this content
Collapse All Expand All Language Filter : AllVisual Basic

C#

C++

J#

JScript

XAML

F#

Visual C++
Compiling a Native C++ Program from the Command Line (C++)Updated: July 2009

Visual C++ includes a C++ compiler that you can use to create everything from simple Visual C++ programs to Windows Forms applications and components.

In this procedure, you create simple Visual C++ programs by using a text editor and compile them on the command line.

You can also compile Visual C++ programs that you created with a text editor by using the Visual Studio development environment. See Compiling a C++ Program that Targets the CLR in Visual Studio (C++) for more information.

You can use your own Visual C++ programs instead of typing the simple programs shown in these procedures. You can also use any of the Visual C++ code sample programs in the help topics.

Prerequisites
These topics assume that you understand the fundamentals of the C++ language. If you are just getting started learning C++, we recommend the "C++ Beginner's Guide," written by Herb Schildt, available online at http://go.microsoft.com/fwlink/?LinkId=115303.

To create a Visual C++ source file and compile it on the command line
Open the Visual Studio 2008 Command Prompt window.

Click the Start button, point to All Programs, Microsoft Visual Studio 2008, Visual Studio Tools, and then click Visual Studio 2008 Command Prompt.

Depending on your operating system and configuration, you may need to open the Visual Studio 2008 Command Prompt with Administrator privileges to compile the code successfully using the steps described in this topic. To do this, right-click on Visual Studio 2008 Command Prompt and select Run as administrator. Then set the following directory as the current directory at the command prompt: \Program Files\Microsoft Visual Studio <version>\VC.

Note:
The Visual Studio 2008 Command Prompt automatically sets up the correct path of the Visual C++ compiler and any needed libraries. Use it instead of the regular Command Prompt window. For more information, see Setting the Path and Environment Variables for Command-Line Builds.


At the command prompt, type notepad simple.cpp and press Enter.

Click Yes when you are prompted to create a new file.

In Notepad, type the following lines:

Copy Code
#include <iostream>

int main()
{
std::cout << "This is a native C++ program." << std::endl;
return 0;
}
On the File menu, click Save. You have created a Visual C++ source file.

On the File menu, click Exit to close Notepad.

At the command prompt, type cl /EHsc simple.cpp and press Enter. The /EHsc command-line option instructs the compiler to enable C++ exception handling. For more information, see /EH (Exception Handling Model).

The cl.exe compiler generates an executable program simple.exe.

You can see the executable program name in the lines of output information that the compiler displays.

To see a list of all files in the directory named simple with any extension, type dir simple.* and press Enter.

The .obj file is an intermediate format file that you can safely ignore.

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

The program displays this text and exits:

This is a native C++ program.

To close the Command Prompt window, type exit and press Enter.

Compiling a Visual C++ Program That Uses .NET Classes
This procedure shows the command line that you use to compile a Visual C++ program that uses .NET Framework classes.

You must use the /clr (Common Language Runtime Compilation) compiler option because this program uses .NET classes and requires the Visual C++ compiler to include the necessary .NET libraries. The Visual C++ compiler generates an .exe file that contains MSIL code instead of machine executable instructions.

You can follow the steps in this procedure to compile any sample Visual C++ program in the help topics.

To compile a Visual C++ .NET console application on the command line
Open the Visual Studio 2008 Command Prompt window.

Click the Start button, point to All Programs, Microsoft Visual Studio 2008, Visual Studio Tools, and click Visual Studio 2008 Command Prompt.

Depending on your operating system and configuration, you may need to open the Visual Studio 2008 Command Prompt with Administrator privileges to compile the code successfully using the steps described in this topic. To do this, right-click on Visual Studio 2008 Command Prompt and select Run as administrator. Then set the following directory as the current directory at the command prompt: \Program Files\Microsoft Visual Studio <version>\VC.

At the command prompt, type notepad simpleclr.cpp and press Enter.

Click Yes when you are prompted to create a new file.

In Notepad, type the following lines:

Copy Code
int main()
{
System::Console::WriteLine("This is a Visual C++ program.");
}
On the File menu, click Save.

You have created a Visual C++ source file that uses a .NET class (Console) and is located in the System namespace.

On the File menu, click Exit to close Notepad.

At the command prompt, type cl /clr simpleclr.cpp and press Enter. The cl.exe compiler generates an executable program simpleclr.exe.

To see a list of all files in the directory named simpleclr with any extension, type dir simpleclr.* and press Enter.

The .obj file is an intermediate format file that you can safely ignore.

The .manifest file is an XML file that contains information about the assembly. (An assembly is the .NET unit of deployment, such as an .exe program or .dll component or library.)

To run the simpleclr.exe program, type simpleclr and press Enter.

The program displays this text and exits:

This is a Visual C++ program.

To close the Command Prompt window, type exit and press Enter
See it's stuff like this that makes me lose faith in VC++. It would be just as easy and twice as conveniant for the end user to add the directory of the C++ compiler to PATH on installation. But no, instead they send users digging around in the command prompt for no real reason.

What's the error your getting when you try to run the debugger? Please copy paste or screen shot.
I cant copy and paste its on my laptop but I will write it out as it states it:

*Unable to start program 'C:\Windows\system32\regsvr32.exe'.

The debugger does not support debugging managed and native code at the same time on this platform.*


(It builds it fine)
are you thenking about system("command");?
I am thinking but nothing is really making these gears click I am completely lost I just want to restore the basic settings so I can continue learning the basics.

I am thinking about uninstalling and installing it again yet I figure I have a problem I should figure it out instead of giving up
@ ty98: ???

@ OP: What DLL are you trying to register\load? This tutorial isn't even trying telling you to make one. I'd suggest compiling in release mode or what ever it's called, the normal one and see how that works for you.
I dont know I am just trying to recover the simple.cpp but I messed with it a little bit and I typed in LINK.exe and I typed a bunch of random things it changed things than I went to the property of the command prompt and tried to change the property and I messed things up pretty bad

oh I had tried to compile in the "release mode" the normal one and the error pops up
Last edited on
If you startup the command prompt,

XP: Start -> Run -> Cmd

Vista\7: Start -> Cmd

Then type time tell me what it says on the screen. You may have altered your environments system path settings.

EDIT: While annoying this is nothing to freak out about, not yet anyway.
Last edited on
the current time is: 16:53:07.79
Enter the new time: _
Ok so you didn't over write that setting. It sounds like it maybe didn't compile right? Delete it and try again.
Okay thank you
Topic archived. No new replies allowed.