Recent

Author Topic: [solved] Where are console apps (12.04) - newbie Q.  (Read 2744 times)

zaphodfj

  • Newbie
  • Posts: 2
[solved] Where are console apps (12.04) - newbie Q.
« on: August 15, 2012, 09:08:35 pm »
Hello All,

I've just installed Lazarus from the Xubuntu repositories.  It works in Windows, but, a plain old 'hello world' program doesn't appear to do anything.

I've created it through: project/new project/program.

The code is below - the only thing I have added is the Writeln ('hello world'):

I press F9 - it compiles, but I see nothing (in Windows, a terminal window pops up).

What am I doing wrong?

Thanks!

Quote
program Project1;

{$mode objfpc}{$H+}

uses
  {$IFDEF UNIX}{$IFDEF UseCThreads}
  cthreads,
  {$ENDIF}{$ENDIF}
  Classes
  { you can add units after this };

{$R *.res}

begin
  writeln('Hello world');
end.
     
« Last Edit: August 15, 2012, 09:32:31 pm by zaphodfj »

Laksen

  • Hero Member
  • *****
  • Posts: 621
    • J-Software
Re: Where are console apps (12.04) - newbie Q.
« Reply #1 on: August 15, 2012, 09:24:36 pm »
On linux you need to launch it using a host terminal to view the console output. That's just how it works there. Debugging is tricky when running applications through such a host as far as I remember. Some actual linux users might be able to fill you in better. Otherwise search the forums. All linux users have had this hurdle :)

You can set up the launching application in Run -> Run parameters.

Simply tick off the box 'Use launching application', and write something like this in the following field:
/usr/bin/xterm -T 'Lazarus Run Output' -e $(LazarusDir)/tools/runwait.sh $(TargetCmdLine)

zaphodfj

  • Newbie
  • Posts: 2
[solved] Re: Where are console apps (12.04) - newbie Q.
« Reply #2 on: August 15, 2012, 09:31:12 pm »
Thank you!
I ticked the box - the line below was already filled in:
/usr/bin/xterm -T 'Lazarus Run Output' -e $(LazarusDir)/tools/runwait.sh $(TargetCmdLine)

In case anyone was thinking "Why didn't you Google it, or RTFM", I did ;-)  Good to have a reason to join the forum!

prof7bit

  • New Member
  • *
  • Posts: 16
Re: [solved] Where are console apps (12.04) - newbie Q.
« Reply #3 on: August 27, 2012, 03:55:59 pm »
I press F9 - it compiles, but I see nothing (in Windows, a terminal window pops up).

View ->Debug Windows -> Terminal Output

will show you the stdout while your programming is running. Its not a full featured terminal emulation but it works quite well to view simple writeln() output.

If you disable the debugger (Tools -> options -> debugger -> General: Debugger = None)
*and* in your project options -> compiler options -> Win32 GUI Application is unchecked (should already be by default for console programs) then instead of the above mentioned pseudo terminal a real terminal (usually your default /etc/alternatives/x-terminal-emulator) will pop up and you will have fully working stdin/stdout like if you were running it from the console directly. This is NOT what others have mentioned by changing the run parameters (leave them alone for that to work), this terminal is invoked directly by TProcess while the IDE is executing your program.

Unfortunately this only works while the debugger is set to "none".
« Last Edit: August 27, 2012, 03:58:20 pm by prof7bit »