Author Topic: Console app run/debugging for MacOSX  (Read 16251 times)

bnilsson

  • Guest
Console app run/debugging for MacOSX
« on: November 29, 2006, 09:45:44 pm »
How is the progress on run/debug a console apps from CB on MacOSX?
The xterm launch is not, as we all know, working here.
It would be very handy for number crunching programs that wants input without GUI.
Will it be difficult to fix?

I guess it needs to be interfaced to the regular Terminal program.
Or is there any other solution?


Offline afb

  • Developer
  • Lives here!
  • *****
  • Posts: 884
Re: Console app run/debugging for MacOSX
« Reply #1 on: November 29, 2006, 09:59:29 pm »
Will it be difficult to fix?

It's done, just not fully tested/integrated yet.
http://developer.berlios.de/bugs/?func=detailbug&bug_id=8987&group_id=5358

Quote
I guess it needs to be interfaced to the regular Terminal program.

For a preview of it, here is the patch to apply:
http://developer.berlios.de/patch/?func=detailpatch&patch_id=1667&group_id=5358

And yes, it sends an AppleScript to Terminal.app
« Last Edit: November 29, 2006, 10:03:39 pm by afb »

Offline afb

  • Developer
  • Lives here!
  • *****
  • Posts: 884
Re: Console app run/debugging for MacOSX
« Reply #2 on: November 29, 2006, 10:02:10 pm »
The xterm launch is not, as we all know, working here.

BTW: xterm launch should be working on Mac OS X, but it does assume you
have X11.app running and that /usr/X11R6/bin/xterm is in your PATH...

The code I did will use Terminal.app for wxMac and X11.app/xterm for wxGTK.

bnilsson

  • Guest
Re: Console app run/debugging for MacOSX
« Reply #3 on: November 29, 2006, 11:54:00 pm »
xterm is not working from CB for me.
Trying to "run" a console app called "dxfcnv" with X11 running and the path to xterm in my normal environment:

Quote
Checking for existence: /Users/bnilsson/Documents/Programming/Active/CB_projects/dxfcnv/dxfcnv
Executing: xterm -T 'dxfcnv' -e 'LD_LIBRARY_PATH=.:$LD_LIBRARY_PATH "/Users/bnilsson/Documents/Programming/Active/CB_projects/dxfcnv/dxfcnv" ' (in /Users/bnilsson/Documents/Programming/Active/CB_projects/dxfcnv/.)
Process terminated with status 255 (0 minutes, 0 seconds)

I also tried adding "/usr/X11R6/bin" to Compiler and.. Settings -> Programs -> Additional Paths and there was a difference:
(I need to have "/opt/local/bin" there, otherwise wx-config don't run. Strange, but true.)
Quote
Checking for existence: /Users/bnilsson/Documents/Programming/Active/CB_projects/dxfcnv/dxfcnv
Executing: xterm -T 'dxfcnv' -e 'LD_LIBRARY_PATH=.:$LD_LIBRARY_PATH "/Users/bnilsson/Documents/Programming/Active/CB_projects/dxfcnv/dxfcnv" ' (in /Users/bnilsson/Documents/Programming/Active/CB_projects/dxfcnv/.)
Process terminated with status 1 (0 minutes, 0 seconds)

I do not know the difference between 255 and 1 in this case. Anyway, no activity was seen in the running X11 application.

I will try the Terminal patch and see what's happens.

Offline afb

  • Developer
  • Lives here!
  • *****
  • Posts: 884
Re: Console app run/debugging for MacOSX
« Reply #4 on: November 30, 2006, 12:06:30 am »
You need to have three things:
  • /usr/X11R6/bin in your $PATH
  • :0.0 in your $DISPLAY
  • X11.app up and running


With that, you should be able to do:
Code
xterm -e 'read'
and it should open an X11 xterm ?

Note: you might want to get xterm going by itself, before trying to use it from within Code::Blocks ? (i.e. the xterm commands that C::B is executing should be working if you run them in a Terminal)

Offline afb

  • Developer
  • Lives here!
  • *****
  • Posts: 884
Re: Console app run/debugging for MacOSX
« Reply #5 on: November 30, 2006, 12:34:23 am »
On second thought, it might not be possible to do that in the wxMac version of Code::Blocks - you might need to run the wxGTK version of it, or just apply/wait for the Terminal.app patch.

bnilsson

  • Guest
Re: Console app run/debugging for MacOSX
« Reply #6 on: November 30, 2006, 10:25:05 pm »
I guess what might be missing for me is that CB is not aware of any $DISPLAY.
Can I set this somewhere?
"Compiler..Settings -> Custom variables" is not doing the trick.

(And the patch did not do any difference, still xterm)
Quote
Checking for existence: /Users/bnilsson/Documents/Programming/Active/CB_projects/dxfcnv/dxfcnv
Executing: xterm -T 'dxfcnv' -e DYLD_LIBRARY_PATH=.:$DYLD_LIBRARY_PATH "&quote&"/Users/bnilsson/Documents/Programming/Active/CB_projects/dxfcnv/dxfcnv"&quote&"  (in /Users/bnilsson/Documents/Programming/Active/CB_projects/dxfcnv/.)
Process terminated with status 1 (0 minutes, 0 seconds)

Offline afb

  • Developer
  • Lives here!
  • *****
  • Posts: 884
Re: Console app run/debugging for MacOSX
« Reply #7 on: November 30, 2006, 11:37:17 pm »
I guess what might be missing for me is that CB is not aware of any $DISPLAY.
Can I set this somewhere?
"Compiler..Settings -> Custom variables" is not doing the trick.

I set it in /etc/profile.

Quote
(And the patch did not do any difference, still xterm)

It's a preference, so if you have an old setting of xterm
you probably want to change it to the new "osascript..."

bnilsson

  • Guest
Re: Console app run/debugging for MacOSX
« Reply #8 on: December 01, 2006, 07:38:41 am »
Non comprendo:
Quote
It's a preference, so if you have an old setting of xterm
you probably want to change it to the new "osascript..."
Please explain?

Offline afb

  • Developer
  • Lives here!
  • *****
  • Posts: 884
Re: Console app run/debugging for MacOSX
« Reply #9 on: December 01, 2006, 09:44:15 am »
In the C::B Settings > Environment dialog:
("Terminal to launch console programs in:")

For wxMac (patched), this should be:
Code
osascript -e 'tell app "Terminal" to do script "$SCRIPT"'

For wxGTK (e.g. linux), it is instead:
Code
xterm -T $TITLE -e

Worst case, wiping the preferences works.

Offline afb

  • Developer
  • Lives here!
  • *****
  • Posts: 884
Re: Console app run/debugging for MacOSX
« Reply #10 on: December 01, 2006, 09:49:03 am »
Also, I revised the wxMac code to not use AppleScript quotes ("&quote&") unless your command actually contains $SCRIPT.

bnilsson

  • Guest
Re: Console app run/debugging for MacOSX
« Reply #11 on: December 01, 2006, 03:30:23 pm »
As usual, I feel a bit stupid, but this is what I get using Terminal...
Quote
Last login: Fri Dec  1 15:27:09 on ttyp6
Welcome to Darwin!
You have mail.
$SCRIPT
executing /etc/profile...
executing /etc/bashrc...
executing .bash_login...
mc2-p039:~ bnilsson$ $SCRIPT
mc2-p039:~ bnilsson$

Offline afb

  • Developer
  • Lives here!
  • *****
  • Posts: 884
Re: Console app run/debugging for MacOSX
« Reply #12 on: December 01, 2006, 03:41:37 pm »
the code snippets above was for Code::Blocks.
$TITLE then gets replaced with the projects title,
and $SCRIPT gets replaced with an AppleScript

Unless you have some complex settings, the
easiest is probably to move away the old folder
at ~/Library/Application\ Support/CodeBlocks ?

bnilsson

  • Guest
Re: Console app run/debugging for MacOSX
« Reply #13 on: December 01, 2006, 04:02:46 pm »
Sorry if I was not clear.
The quote was from the Terminal output when I had introduced
Quote
osascript -e 'tell app "Terminal" to do script "$SCRIPT"'
in the Environment settings and done "run" of my console app from within Code::Blocks.

Removing ~/Library/Application \Support/codeblocks did not make any difference.
« Last Edit: December 01, 2006, 04:06:19 pm by bnilsson »

Offline afb

  • Developer
  • Lives here!
  • *****
  • Posts: 884
Re: Console app run/debugging for MacOSX
« Reply #14 on: December 01, 2006, 04:08:53 pm »
You did install the patch, right ?

Anyway, leave it for now and make another try when it's in the trunk...