Different ways from the same program

Simple program:

with Ada.Text_IO; use Ada.Text_IO;

procedure Hello_World_DOS is
begin
Put_Line(“Hello, world_DOS!”);
New_Line;
end Hello_World_DOS;

Result within Gnat Studio:

D:\ada\project\Hello_World_DOS\hello_world_dos.exe
Hello, world_DOS!

Result in Power Shell

PS D:\ada\project\hello_world_dos> ./hello_world_dos
PS D:\ada\project\hello_world_dos>

No result, how come?

Have you tried to put the “.exe” in the powershell command?

Edit: using tab to autocomplete command

20260420 PowerShell Capture

I’ve written and used Ada a lot for terminal programs on Windows and never run into this. What code page do you have selected (I.e what does the chcp command report?)?

Which Windows version are you running? Are you running powershell from inside GNAT studio or separately? Does running from a command prompt (cmd) window give this as well? I would also try the Windows Terminal app if you have it.

I have tried cmd. No output. I am running Windows 11 including the last updates. With earlier versions the problem was the same. I am running powershell separately. chcp active code page 850

The windows terminal app starts powershell, I am using that as administrator.

I have been using the .exe as well

If I use MSYS2 mingw64 the it works.

In the .gpr file you use to build the app with, in the package Linker, did you use the “-mwindows" switch ?

Yes I can see that.

The .gr file is:

project Hello_World_DOS is
for Main use (“Hello_World_DOS.adb”);
for Source_Dirs use (“./src”);
package Linker is
for Default_Switches (“Ada”) use (“-mwindows”);
end Linker;
end Hello_World_DOS;

Well, that means that your application is activated without a console, i.e. it is considered a GUI application. That happens even if you start the app from a cmd/PowerShell console.

Under MSYS2 in an emulated tty this is handled differently, so under MSYS it appears to work.

So, in general, for applications that write to standard output do not use ‘‘-mwindows”’ in your .gpr file

Where is your object directory located? Gnat default put the executable in obj directory.

RobG9876 Got out the complete Linker. It worked. Thanks

DelusionalMuppet. If you do not specify the position of the object file, Gnat Studio chooses a standard position, So if you don’t care Just let the compiler choose.

Hereby I think the question is solved.