Wednesday 22 April 2009

How to DEBUG COMMANDLINE PROGRAMS in VS2008

This is for less knowledgeable people like me....It took me 3 days to figure it out... I googled a lot and never managed to get an answer for this....either it is assumed too simple and obvious or ..........

Debugging a code which runs via a command line where you type in executable file name and arguments to be passed to it....

e.g. executable file name -> lp_solve
@command line
>>lp_solve [input arguments]
>>lp_solve model.lp

You cannot debug this file just by clicking the debug option as the "argc" and "argv" will never get initialized.

There is very simple setting in VS2008 (it might work for other versions of VS but is not tested).

1] Go to project->properties
2] In properties -> Configuration properties -> Debugging
3] Debugging opens a tabular structure in the right half
4] Select Command Arguments
5] Type all the input arguments in double quotes in Command Arguments (you are done)

6] Close the dialogue box, put some break points and click on the play button in debug

Thanks to Cibin George for his valuable input.

....moral of the story consult the experts. If you can google it in 3 hrs you cannot in 3 days....

(SIMPLE THINGS in LIFE are NOT ALWAYS OBVIOUS)

No comments: