Author Topic: How to open a console window in debug mode.  (Read 33938 times)

Offline josue

  • Single posting newcomer
  • *
  • Posts: 4
How to open a console window in debug mode.
« on: December 08, 2008, 02:43:27 am »
Hi,

I have just installed CB and it is running fine. I have also installed GDB and is is working OK, as well.
Now that I am debuging my programs I want to see the progress (output) of them on a console window, under Linux.

For instance, I have a line like this: printf ("Hello world.");
How can I force CB, in debug mode, to open a console window to see that output (Hello World) on the screen?
Note: I set the program as a console aplication.

Thanks for any help.

Regards,
Josué
[/color]

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: How to open a console window in debug mode.
« Reply #1 on: December 08, 2008, 07:39:04 am »
If you set your build target type to console application you should always get an output window.

If you use the wizard to create a console application, the settings are made automatically, if you started with an empty project, it should also be there.

Whatsoever:
Right-click on your project in the management pane and chose "Properties... -> Build targets".
Make sure the type is set to "Console application" and check "Pause when execution ends", or the console closes immediately after the application ends.

Offline josue

  • Single posting newcomer
  • *
  • Posts: 4
Re: How to open a console window in debug mode.
« Reply #2 on: December 09, 2008, 11:11:30 am »
Hi Jens,

Thanks for your reply!
Yes, I did everytheng you suggested. My build target seems to be ok. (console application)
But the outpu window still did not appear.
Please find attached a screenshot for more details.
Thanks for the help.

Regards,
Josué

[attachment deleted by admin]

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5915
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: How to open a console window in debug mode.
« Reply #3 on: December 15, 2008, 09:10:41 am »
It is easy to create a console project using wizard.
If you want to change your target , see the attachment picture.

Property->build targets

[attachment deleted by admin]
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline josue

  • Single posting newcomer
  • *
  • Posts: 4
Re: How to open a console window in debug mode.
« Reply #4 on: December 15, 2008, 11:45:30 pm »
Hi ollydbg,

Thanks for your reply!
I am new in Linux and this is the first time I am using CodeBlocks, so I have very basic doubts.

I have done as you suggest in the first time I created the project.
I have been thinking about this problem the last 7 days and found the solution some minutes ago.
I just needed to install a program called "xterm".

I notice in Settings->Enviroment a setting like this:
Terminal to launch console programs: xterm -T $TITLE -e

So I tried to run the xterm program in a Konsole Terminal but the system did no found it.
Then I installed xterm in my computer and now I can see the output of my console program in a console window.
That's great!
Maybe this is the solution for many people that have this problem.

Best regards for You and for Jens for the attention.
Merry Christmas and Happy New Year for all of you!

Josué

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5915
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: How to open a console window in debug mode.
« Reply #5 on: December 16, 2008, 06:43:32 am »
OK, Thanks , the same to you!

The most important thing I think is the beginner's question should be answered(even if you're a advanced user, you think their question is easy and naive), or they will quickly lose their interests in code::blocks.

So, If you have time, you can also help others in this forums.
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

ukh

  • Guest
Re: How to open a console window in debug mode.
« Reply #6 on: April 02, 2009, 06:44:40 pm »
Hi to josue, jens and ollydbg,

I have the also problems like josue, but no solution. :(
On my linux-system the xterm is installed and the
Properties... -> Build targets settings are set to console application.
in release and debug mode

If I run the hello world program in release mode everything is
fine. In  debug mode everything is fine, using gdb in debug mode no xterm is visible. Is there any other setting
that is missing?

It seams, that the Debugger gdb is not able to start or attach to a xterm

CB version 8.02, build mar 13 2009


Thanks for any help
« Last Edit: April 02, 2009, 07:04:14 pm by ukh »

Offline littlegene

  • Multiple posting newcomer
  • *
  • Posts: 30
Re: How to open a console window in debug mode.
« Reply #7 on: February 03, 2012, 12:54:00 pm »
I work on Windows. And I debug a static library with host application. The host console application is mine as well.
Everything is ok except for I do not see a console output, really. May I arrange settings so that to see the output of the console applicatio? Or it is impossible.

Thanks.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: How to open a console window in debug mode.
« Reply #8 on: February 03, 2012, 02:11:10 pm »
Please try to explain you problem a bit more thoroughly, because I don't understand what exactly is the problem.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline littlegene

  • Multiple posting newcomer
  • *
  • Posts: 30
Re: How to open a console window in debug mode.
« Reply #9 on: February 03, 2012, 03:55:29 pm »
Ok.
1. I have a workspace with 2 projects - a simple console mode application and a static library that is used (being linked) by this particular app.
2. I've succesfully compiled and build all the stuff and I see, that the appication links the library archive (libxxx.a) as required.
3. I run the app (after setting the app project active) and I see that it works. I see the console window and output messages on it.
4. Now I should fix some bugs in a static archive (not in app)
5. So I turn 'active project' to the static archive (library) and set breakpoints all other the code (inside library body and inside app body)
6. Because launching the library is not possible with no host application, I do it (my host application is still this particular application)
7. So, If I just press Ctrl-F10 when library is active project, everything is ok - I see the console window.
8. But if I am in debug mode - (F8) I do not see the console window. It is not appear all the time even after I remove all existing breakpoints and continue execution.
9. Debugging process itself is fine. But I must see the console window as well.

p.s.
I use cygwin compiler and debugger on Windows.
Maybe this is the trouble.
I just wanted to learn, if this is the correct behaviour or not.


update:
It seems I have a solution. )  If I debug starting when app is active porject - I see console window and I step into the body of static library as well. ))
« Last Edit: February 03, 2012, 04:08:56 pm by littlegene »

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: How to open a console window in debug mode.
« Reply #10 on: February 03, 2012, 04:39:00 pm »
Two ways to solve it:
1. Install a debugger's branch nightly build and set 'Projects->Set project's arguments->Run host in terminal'.
   Probably you can have problems with breakpoint and cygwin with the debugger's branch version
2. Simple debug your application and put some breakpoints in the library (your application is the active project for debugging).
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]