Author Topic: "Hello, World!" doesn't work on Windows 11 whith this unit in the USES list.  (Read 536 times)

Ñuño_Martínez

  • Hero Member
  • *****
  • Posts: 1240
    • Burdjia
I need some confirmation and help with this weird bug.

See next code:

Code: Pascal  [Select][+][-]
  1. program test;
  2. {$IfDef WINDOWS}{$R 'manifest.rc'}{$EndIf}
  3. begin
  4.   WriteLn ('Hello, World!')
  5. end.

It works.  No problem.  But then, add just one unit to the uses clause:
Code: Pascal  [Select][+][-]
  1. program test;
  2. {$IfDef WINDOWS}{$R 'manifest.rc'}{$EndIf}
  3. uses
  4.   allegro5;
  5. begin
  6.   WriteLn ('Hello, World!')
  7. end.

Then WriteLn refuses to print anything.  But I remember that two or three months ago it did work.  I suspect it is because Micro$oft replaced the good old cmd with PowerShell but I'm not sure.

Can you please download Allegro.pas from here and test if second program work or doesn't? 

I'll also appreciate if you can provide more information about why this behaviour and a possible fix or workaround.


Are you interested in game programming? Join the Pascal Game Development community!
Also visit the Game Development Portal

Thaddy

  • Hero Member
  • *****
  • Posts: 19966
  • Pointless static linking author
I would have to create a new VM -or better a new machine- . That is a bit over the top. Did you check your own code? I can make all others check it....
rc only should not work at all, it should also refer to res or only refer to res.
This should throw an error: {$IfDef WINDOWS}{$R 'manifest.rc'}{$EndIf}
« Last Edit: September 18, 2026, 03:13:03 pm by Thaddy »
Any "programmer" that knows only one programming language is not a programmer

Remy Lebeau

  • Hero Member
  • *****
  • Posts: 1613
    • Lebeau Software
rc only should not work at all, it should also refer to res or only refer to res.
This should throw an error: {$IfDef WINDOWS}{$R 'manifest.rc'}{$EndIf}

Not true. See https://wiki.freepascal.org/Lazarus_Resources

Quote
Use
- {$R filename.rc} to compile a resource script and include the resulting resource file or
- {$R filename.res} directive to include a compiled resource file
« Last Edit: September 18, 2026, 10:13:43 pm by Remy Lebeau »
Remy Lebeau
Lebeau Software - Owner, Developer
Internet Direct (Indy) - Admin, Developer (Support forum)

Thaddy

  • Hero Member
  • *****
  • Posts: 19966
  • Pointless static linking author
Yes, seems so. Confused with Delphi.
Any "programmer" that knows only one programming language is not a programmer

Remy Lebeau

  • Hero Member
  • *****
  • Posts: 1613
    • Lebeau Software
Yes, seems so. Confused with Delphi.

In Delphi, the {$R} directive does not allow an .rc file to be specified by itself, only an .res or DFM file. But, it does allow an .rc file to be specified in combination with a .res file, eg:

{$R filename.res filename.rc}

filename.rc will be compiled into filename.res, and then filename.res will be linked in to the final executable.
« Last Edit: September 19, 2026, 08:42:49 pm by Remy Lebeau »
Remy Lebeau
Lebeau Software - Owner, Developer
Internet Direct (Indy) - Admin, Developer (Support forum)

Soner

  • Sr. Member
  • ****
  • Posts: 348
...
Can you please download Allegro.pas from here and test if second program work or doesn't? 
..
I'm getting error, Lazarus 4.8-fixes, fpc 3.2.2, Win 11, all 64 Bit.

Perhaps Allegro5..dll itself is causing the error.
I downloaded it from here:
https://github.com/liballeg/allegro5/releases/tag/5.2.11.3
this:
allegro-i686-w64-mingw32-gcc-15.2.0-posix-dwarf-dynamic-5.2.11.3

Edit:
Testprogramm runs and print out "Hello World" without uses allegro5; So Allegro 5 dll is causing the error.
« Last Edit: September 20, 2026, 09:16:07 am by Soner »

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 13018
  • FPC developer.
FPC is SEH on Windows, so a SEH DLL would be more logical than a DWARF (exception frames) DLL on Windows.

Soner

  • Sr. Member
  • ****
  • Posts: 348
Same error with SEH DLL, error  0xc000007b.
I searched for the error 0xc000007b, but the example programm and allegro libs are 64 Bit.

Ñuño_Martínez

  • Hero Member
  • *****
  • Posts: 1240
    • Burdjia
Thanks all for the answers.

rc only should not work at all, it should also refer to res or only refer to res.
This should throw an error: {$IfDef WINDOWS}{$R 'manifest.rc'}{$EndIf}
IIRC I added that line to improve compatibility between FreePascal and Delphi, and it came from a discussion in the forums long time ago.

Not true. See https://wiki.freepascal.org/Lazarus_Resources
Maybe not related but I should read that article.  Thanks,

FPC is SEH on Windows, so a SEH DLL would be more logical than a DWARF (exception frames) DLL on Windows.
So allegro5.dll might be the culprit.  I suspect it as previously I found other incompatibility issues with GUI (Allegro define a few routines to show message boxes, file dialogs and create menus that don't work as they should when called from Pascal) and threads (Allegro define it's own thread management and seems not compatible with the RTL ones so I didn't include it in the package).

Is there a workaround?

I'm getting error, Lazarus 4.8-fixes, fpc 3.2.2, Win 11, all 64 Bit.

Perhaps Allegro5..dll itself is causing the error.
I downloaded it from here:
https://github.com/liballeg/allegro5/releases/tag/5.2.11.3
this:
allegro-i686-w64-mingw32-gcc-15.2.0-posix-dwarf-dynamic-5.2.11.3

Edit:
Testprogramm runs and print out "Hello World" without uses allegro5; So Allegro 5 dll is causing the error.

Same error with SEH DLL, error  0xc000007b.
I searched for the error 0xc000007b, but the example programm and allegro libs are 64 Bit.

Thanks both for the testing.  I've found that PowerShell is completely silent while CMD (which I found it still exists but must be executed using [Win]+[R]) does return that 0xc000007b error.

Maybe compiling Allegro myself would fix something?  But it uses configure and I have no idea how it works (I tried to learn how it works time ago but my brain almost melted).
Are you interested in game programming? Join the Pascal Game Development community!
Also visit the Game Development Portal

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 13018
  • FPC developer.
Thanks both for the testing.  I've found that PowerShell is completely silent while CMD (which I found it still exists but must be executed using [Win]+[R]) does return that 0xc000007b error.

Maybe compiling Allegro myself would fix something?  But it uses configure and I have no idea how it works (I tried to learn how it works time ago but my brain almost melted).

The error comes before the compiled program actually starts, so probably during the DLL initialization or so. Might be missing runtime loaded dependencies (MSVCRT dependence or other mingw dlls )

According to Google AI it is a 32-bit/64-bit mismatch, but all the DLLs and the exe are 64-bit  (PE32+), checked with cygwin "file" command. So it must be something they depend on, or try to load.
« Last Edit: September 20, 2026, 12:21:02 pm by marcov »

jamie

  • Hero Member
  • *****
  • Posts: 8031
Re: "Hello, World!" doesn't work on Windows 11 whith this unit in the USES list.
« Reply #10 on: September 20, 2026, 02:01:49 pm »
Doing a little research, it appears that Version is done in C++ whereas version 4 was C.

 are there any miscalls to the API's ?, who knows.

 but I would also test trying to run the test demo here without DEBUG.

Jamie
The only true wisdom is knowing you know nothing

 

TinyPortal © 2005-2018