Debug a Microsoft Visual C++ Program

Note: This section applies only to programs being debugged on Windows NT.

You can use the debugger to debug programs compiled by the Microsoft Visual C++ Compiler Version 5.0, provided the debug information is imbedded in the executable. Both C and C++ programs are supported. To debug such a program follow these steps:

  1. Use the Visual C++ compiler to compile the program with the /Z7 option, to produce Microsoft C 7.0 debug information.
  2. Link the .obj files with the /DEBUG and /PDB:NONE linker options to generate the necessary debug information and imbed it in the executable.
  3. Start debugging the program.

For example, to compile, link, and debug the program hello.c, use the following commands:

cl /Z7 /c hello.c
link /DEBUG /PDB:NONE hello.obj /OUT:hello.exe
idebug hello.exe

If you do not compile and link with these options, debug information, if generated, is stored in a separate .PDB file which the debugger cannot read. In this case the debugger treats the executable as if it had no debug information, and only disassembly views of the code are available.



Start the Debugger


Limitations when Debugging Visual C++ Programs