Debug VC++ app in command line - windows

Is it possible to debug a vc++ application in command line? I mean, is there any windows dos debugging tool like gdb that I can use to debug a vc++ application in command line (DOS)?

Have you tried the .NET Framework Command-Line Debugger? If you have the Visual Studio IDE installed, open the command prompt from the VS Tools, and you're good to go.
http://msdn.microsoft.com/en-us/library/ms229861.aspx
And another option: http://msdn.microsoft.com/en-us/windows/hardware/gg463009.aspx

Related

How to run VS Code program on command prompt?

New to both VS Code and Visual Studio... When I run my C# program in Visual Studio, the command prompt opens and the program is run there. In VS Code however, the program is run in the integrated debug console.
Is there a way I can set VS Code to open up cmd prompt and run my program there, rather than the VS Code debug console?
Thanks.
Go to settings and search "Terminal: Explorer Kind". Then set it to external select external.

'psxevars command not found' when enabling Intel Fortran

I installed the non-commercial intel Fortran 2018 in Windows 10. According to the starting guide, I should run psxevars.bat. But when I typed 'psxevars' in cmd. It showed 'psxevars command not found'. So I used another way, double clicking it in windows. Then I try ifort in cmd. It doesn't work. It showed 'ifort command not found'. How can I make it work? Btw, I used the cmd in the product group from start menu.
First, make sure Visual Studio (e.g. Visual Studio Community 2015 version) is installed before installing Intel Parallel Studio.
After installing Intel Parallel Studio successfully, a "command line prompt" should be listed at the start menu like this:
There is no need to run psxevars.bat because the installing process has already done this for us.
Another situation might be that we try to use Intel tools in Windows command-line prompt through the cmd command. In this case, we need to run psxevars.bat. And do not forget to specify two arguments, arch and vs, as shown in below.
And notice that it only takes effects in this command-line window, i.e. the same running need to be done for every cmd command-line prompt.
an eternal way is to set the environment variable. Add directories containing Intel tool executables to the "PATH" environment variable, and other related things(libs, include).
On Windows, I recommend using Intel Parallel Studio with the Visual Studio IDE.

Env vars for Visual Studio command prompt

I'm doing an RDP into a machine that has just the CLR installed, and doesn't have Visual Studio on it. Can I somehow load all the Visual Studio-specific environment variables on to the regular command prompt and convert it into the VS command prompt so that I'm able to build my projects via command line?
I looked at the vcvarsall.bat file. That calls the appropriate processor-specific batch file. Couldn't get any inputs from there.
Short of installing all VS, or tracing thru all the various batch files to find out what's getting set, you may be able to simply capture the env vars that are set.
Open up a VS command prompt, and run set > vars.bat
Then open up vars.bat, and put a set command in front of each line.
Not sure how much this will help, since you're going to be missing all the utilities that come with Visual Studio, but it does answer your question.
I don't recommend trying to copy only what you need. You'll need other header files, libraries, dlls, etc... You can instead install VS express edition.
If you are trying to debug a problem you can use remote debugging in Visual Studio or use WinDbg on the computer.

Visual Studio Command Prompt vs. a regular command prompt?

When I open a Visual Studio command prompt (for example, opened with menu Start -> Programs -> Microsoft Visual Studio 2008 -> Visual Studio Tools -> Visual Studio 2008 Command Prompt), I get:
Setting environment for using Microsoft Visual Studio 2008 x86 tools.
C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE>
What kind of tools are available, and what are the most common uses of this command prompt?
It basically just sets several of the Visual Studio binary locations into the PATH environment variable for that command window instance. This means you can use all the various commands and tools without having to include the full paths.
There's a partial list of some of the tools available on MSDN in .NET Framework Tools and Tools (.NET Framework).
The Visual Studio command prompt is a convenient way to access the command line tools that ship with the .NET Framework SDK and, if installed the, Windows Platform SDK tools.
By providing the Visual Studio command prompt, Microsoft allows you to run these tools without requiring your PATH, INCLUDE, LIB and LIBPATH environment variables to contain all the additional paths to the various folders where Visual Studio and the .NET SDK are installed. Instead, these folder references are added on the fly when you start the Visual Studio command prompt allowing you to run the tools.
For example, if you open a regular command prompt you cannot run xsd.exe without changing to the directory "C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin". However, in the Visual Studio command prompt you can just type xsd.exe /?, and it works.
Please see the MSDN article .NET Framework Tools for a complete list of the tools provided with Visual Studio 2008 SP1 and details on what they do.
The Visual Studio command prompt has a few tools with it. Some tools are for repairing the install of Visual Studio. One of the tools I love using is for WCF. You type wcftestclient and you get a client to test your WCF services.
The article The Visual Studio Command Prompt has a nice explanation:
Let's look at the "Visual Studio Command Prompt" in more detail.
It appears to just set the path for you and put you in (Ta Da!) the VC
directory under Visual Studio. Not even the C# directory and certainly
not the VB directory. I guess they assume that anyone who uses this
tool is really hard core and programs directly against the hard drive
with a magnifying glass and a magnet.
What it actually does is run this DOS command. (In my case.)
%comspec% /k ""C:\Program Files\Microsoft Visual Studio
10.0\VC\vcvarsall.bat"" x86
What does vcvarsall.bat do? Well, it sets the target compiler
environment so you can compile code for a different processor.
One use seems to be to call the XML Class Generator for using XSD schemas for serialization/deserialization:
XML Class Generator for C# using XSD for deserialization
Simple example
After installing Desktop development with C++ as part of the VS Installer, it installs C++ CMake tools for Windows. Let's run this cmake.exe file!
VS Developer Command Prompt
C:\Directory>cmake --version
cmake version 3.21.21080301-MSVC_2
Windows Command Prompt
C:\Directory>cmake --version
'cmake' is not recognized as an internal or external command,
operable program or batch file.
Why example behaves as it does
The VS Developer Command Prompt knew the command cmake, yet the Windows command prompt didn't.
Its almost as if it is and isnt a path variable - Schrodingers cat, errr path!
So where is cmake.exe that the VS developer command prompt says it knows about?
VS Developer Command Prompt
C:\Directory>where cmake
C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe
Okay so that means C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\ must be a PATH variable.
Lets double check:
C:\Directory>set PATH
Path=C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin;
It is, great. Now why didnt the windows command prompt find it?
Windows Command Prompt
C:\Directory>set PATH
Hmmm, I'm looking at the list and its not there.
Now Simon Steven's and MikeD's answer can be put in context:
It basically just sets several of the Visual Studio binary locations into the PATH environment variable for that command window instance. This means you can use all the various commands and tools without having to include the full paths.

How can i debug in visual studio as command line?

I hav my execuatable produced by command line building.
I want to debug it in command line itself as like as gdb does in linux.
Also i want run my program in Visual studio GUI from command line options..
How can i do that?
Make sure it is compiled in the debug version. Run the program. Then "Attach to Process" from VS tools menu.
You can also specify the runtime options when running the debugger (it's in the project properties).
I don't think that VS has a pure command line mode, but you could use CDB/NTSD.
http://msdn.microsoft.com/en-us/library/cc266320.aspx
It is what lots of developers at MS do.

Resources