Build proper debug symbols with VC

0 Likes

Problem:

What build options must I use to prepare an application for debugging? I am building with VC .

Resolution:

There are two debug formats that you can use. C7 style debug builds the debug information directly into the binary of the exe, dll, sys, etc. Program DataBase format (Zi) builds the debug into a .pdb file.

First you should be sure that you active project is the debug build. This is set in Visual Studio under the build menu > set active configuration.

The C7 build:

Compiler -

/Z7 - This is comparable to Visual Studio under Projects Settings, then the C/C tab, in the Category list box have General selected. Then in the Debug info list box select C7 Compatible).

/Od - This is comparable to Visual Studio under Projects Settings, then the C/C tab, in the Category list box have General selected. Then the optimizations should be Disable (Debug).

Linker -

/incremental:no - In Visual Studio it is under Projects Settings, then the Link tab, the link incrementally box should not be checked).

/debug - In Visual Studio it is under Projects Settings, then the Link tab, under the category Debug. The Debug Info check box should be checked.

/debugtype:cv - In Visual Studio it is under Projects Settings, then the Link tab, under the category Debug. The Debug Info radio button should be Microsoft Format. "Note the /debugtype:cv is the default and does not show it can be added manually in the text box."

/pdb none - The default is the filename so this will need to be added in the text box manually.

The Zi build:

Compiler -

/Zi - This is comparable to Visual Studio under Projects Settings, then the C/C tab, in the Category list box have General selected. Then in the Debug info list box select Program Database).

/Od - This is comparable to Visual Studio under Projects Settings, then the C/C tab, in the Category list box have General selected. Then the optimizations should be Disable (Debug).

Linker -

/incremental:no - In Visual Studio it is under Projects Settings, then the Link tab, the link incrementally box should not be checked).

/debug - In Visual Studio it is under Projects Settings, then the Link tab, under the category Debug. The Debug Info check box should be checked.

/debugtype:cv - In Visual Studio it is under Projects Settings, then the Link tab, under the category Debug. The Debug Info radio button should be Microsoft Format. "Note the /debugtype:cv is the default and does not show it can be added manually in the text box."

/pdb "Directories/Yourfile.pdb" - This should be there as default if not add it in the text box manually.

/pdbtype:con - In Visual Studio it is under Projects Settings, then the Link tab, under the category Debug. The Separate Types box should be unchecked. "Note the /pdbtype:con is the default and does not show it can be added manually in the text box."

Save the settings and completely clean and rebuild with the new settings.

Old KB# 10992
Comment List
Anonymous
Related Discussions
Recommended