How to RUN Console programs from Lazarus ? lazarus / 13-General ---------------------------------------------------------------------- demosthenesk · 2022-09-29 09:09 Hello, i am learning Free Vision and i write console apps. When i press RUN from lazarus ide the program starts but it does not show up in terminal. I use Ubuntu Linux and i ask help to show up the running app in a terminal console. I can pause and stop program but not show the console. How can i RUN console programs from Lazarus ? ---------------------------------------------------------------------- demosthenesk · 2022-09-29 09:20 ok i found the solution https://wiki.freepascal.org/Console_Mode_Pascal ---------------------------------------------------------------------- MarkMLl · 2022-09-29 09:33 OK, I see you've found the solution but a few extra points. First, when asking about something please put the version numbers of the tools you're using (i.e. Lazarus, FPC) in the body of your message. Also pertinent info about your OS. Second, you've probably seen from that wiki page that there's a console output window which you can use while debugging. However it really is very basic with no support for cursor-positioning escape sequences and so on. An alternative way is to start the program from a shell session, then to use the IDE's Run -> Attach to program... to connect the debugger to the program. That gives you the best of both worlds, since you'll have properly-formatted output but also breakpoints etc. MarkMLl p.s. RUN isn't an acronym, you don't have to capitalise it :-) ---------------------------------------------------------------------- marcov · 2022-09-29 09:39 (Maybe lazarus also have options to execute using another terminal program ? If so, try to run it with xterm, it generally was the most compatible terminal emualtor) ---------------------------------------------------------------------- d2010 · 2025-05-06 19:09 Quote from: marcov on September 29, 2022, 11:39:25 am(Maybe lazarus also have options to execute using another terminal program ? If so, try to run it with xterm, it generally was the most compatible terminal emualtor) Here to check  inside cecolor.dll , the main-program.exe running with "ConsoleAppMode". Inside  Cecolor.dll, the consoleMode was remove by Me. I add function fcnDll_IAmAConsoleApp: Boolean; inside cecolor.lpr.dll Code: [Select]Here is the answer-> Var mywxapp:integer=00; function fcndLL_IAmAConsoleApp: Boolean; var   Stdout: THandle; begin   Stdout := GetStdHandle(Std_Output_Handle);   Win32Check(Stdout <> Invalid_Handle_Value);   Result := Stdout <> 0;   if (result) then  mywxapp:=integer(Stdout); end; ---------------------------------------------------------------------- Martin_fr · 2025-05-06 19:24 From the Lazarus IDE you can use menu: Run > Run Param And set a host application. And then it can run in a terminal of your choice. But that only works WITHOUT debugging. The debugger can not trace into the console host. If you want to debug, you just run the app (without run params / without host app). The in/output is then under menu: View > Debug Windows > Console. This does however not support any "escape" codes (setting colors, or printing at pos, ...) Debugging in a real terminal is only possible with some workarounds, and not easy. In the global debugger settings you can set a redirect to a "pty" => for that you need a console that provides the pty, and then the app while being debugged will be connected there. Or you can play with gdb server. I never tested that, but it might work... kind of... ---------------------------------------------------------------------- d2010 · 2025-05-06 19:43 Quote from: Martin_fr on May 06, 2025, 09:24:26 pmFrom the Lazarus IDE you can use menu: Run > Run Param And set a host application. And then it can run in a terminal of your choice. But that only works WITHOUT debugging. The debugger can not trace into the console host. Thank you, I solved, Thank you, Your solution is good enough for me. ---------------------------------------------------------------------- Thaddy · 2025-05-07 08:21 Quote from: Martin_fr on May 06, 2025, 09:24:26 pmDebugging in a real terminal is only possible with some workarounds, and not easy. Martin, I believe that running the application - with debug info - is quite easy to debug when directly run under gdb. That is at least what I would do and that is not difficult. But I can imagine that a lot of people are so used to GUI supported debugging that they have lost the plot about the art of debugging. (BTW the internal native debugger works great!)