In windows it is a little more tricky compared to Delphi. In Delphi all you need to do is to call AllocConsole
. Using Lazarus/FreePascal you need to do a little extra work:
uses
Windows;
begin
AllocConsole; // in Windows unit
IsConsole := True; // in System unit
SysInitStdIO; // in System unit
// Now you can do Writeln, DebugLn, ...
end.
Unfortunately I cannot help you on other platforms. Although iirc in linux console is always present for a program even if not visible. So it should work without extra code. However I cannot test this atm so take it with a grain of salt.