Hello,
I'm trying to create a basic console application on Windows:
#include <stdio.h>
#include <string.h>
int main() {
char buffer[1024];
fprintf(stdout, "Enter text: ");
if (fgets(buffer, sizeof(buffer), stdin)) {
buffer[strcspn(buffer, "\n")] = '\0';
fprintf(stdout, "You entered: \"%s\"\n", buffer);
} else {
fprintf(stderr, "Error reading input.\n");
return 1;
}
return 0;
}
I compile this with MinGW and bundle it into an app with makeappx.exe
from the Windows SDK:
$ x86_64-w64-mingw32-gcc SimpleApp/simple.c -o SimpleApp/simple.exe
$ /cygdrive/c/Program\ Files\ \(x86\)/Windows\
Kits/10/bin/10.0.26100.0/x64/makeappx pack /d SimpleApp /p Simple.msix
...
Package creation succeeded.
Finally I install this in Powershell using:
PS > Add-AppxPackage -Path .\Simple.msix -AllowUnsigned
PS > Get-AppxPackage -Name "SimpleApp.Simple" | Select-Object
-ExpandProperty InstallLocation
C:\Program Files\WindowsApps\SimpleApp.Simple_1.0.0.0_x64__enwe9x4v0qrt
In Windows Terminal / cmd.exe, this seems to work great.
The problem is that an execution alias does not work under Cygwin / MinTTY:
$ simple_console_app.exe # alias requested in AppxManifest.xml
<hangs in fgets() - nothing is printed to terminal>
However using the application directly from its install path works fine:
$ /cygdrive/c/Program\
Files/WindowsApps/SimpleApp.Simple_1.0.0.0_x64__enwe9x4v0qrtw/simple.exe
Enter text: 1+1
You entered: "1+1"
Is this a conpty or related issue? I don't know how Windows implements
its app execution aliases.
For reference, this is my AppxManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<Package xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
xmlns:uap5="http://schemas.microsoft.com/appx/manifest/uap/windows10/5"
xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"
xmlns:desktop="http://schemas.microsoft.com/appx/manifest/desktop/windows10"
xmlns:desktop4="http://schemas.microsoft.com/appx/manifest/desktop/windows10/4"
IgnorableNamespaces="uap uap5 rescap desktop desktop4">
<Identity Name="SimpleApp.Simple" Publisher="CN=AppModelSamples,
OID.2.25.311729368913984317654407730594956997722=1" Version="1.0.0.0"
ProcessorArchitecture="x64"/>
<Properties>
<DisplayName>SimpleApp</DisplayName>
<PublisherDisplayName>Simple</PublisherDisplayName>
<Logo>Logo.png</Logo>
</Properties>
<Dependencies>
<TargetDeviceFamily Name="Windows.Desktop"
MinVersion="10.0.18362.0" MaxVersionTested="10.0.19043.0" />
<TargetDeviceFamily Name="Windows.Universal"
MinVersion="10.0.18362.0" MaxVersionTested="10.0.19043.0" />
<PackageDependency Name="Microsoft.VCLibs.140.00.UWPDesktop"
MinVersion="14.0.29231.0" Publisher="CN=Microsoft Corporation,
O=Microsoft Corporation, L=Redmond, S=Washington, C=US" />
</Dependencies>
<Resources>
<Resource Language="en-us"/>
</Resources>
<Applications>
<Application Id="Simple" Executable="simple.exe"
EntryPoint="Windows.FullTrustApplication" desktop4:Subsystem="console"
desktop4:SupportsMultipleInstances="true">
<uap:VisualElements DisplayName="Simple" Description="Simple console
app" BackgroundColor="transparent" Square150x150Logo="Logo.png"
Square44x44Logo="Logo.png">
<uap:DefaultTile
ShortName="SimpleApp">
</uap:DefaultTile >
</uap:VisualElements>
<Extensions>
<uap5:Extension Category="windows.appExecutionAlias"
Executable="simple.exe" EntryPoint="Windows.FullTrustApplication">
<uap5:AppExecutionAlias desktop4:Subsystem="console">
<uap5:ExecutionAlias Alias="simple_console_app.exe" />
</uap5:AppExecutionAlias>
</uap5:Extension>
</Extensions>
</Application>
</Applications>
<Capabilities>
<rescap:Capability Name="runFullTrust" />
<rescap:Capability Name="unvirtualizedResources"/>
</Capabilities>
</Package>
Thanks for any help / insights.
Cody T.
--
Problem reports: https://cygwin.com/problems.html
FAQ: https://cygwin.com/faq/
Documentation: https://cygwin.com/docs.html
Unsubscribe info: https://cygwin.com/ml/#unsubscribe-simple