3

I'm trying to run a very simple Haskell program in Windows.

I have Visual Studio 2019 and Windows 11. And have installed the stack for Windows. [stack-2.9.3-windows-x86_64-installer.exe]

stack new hello-world
cd hello-world
stack build

But it throws this error:

    |
819 |   _CRTIMP size_t __cdecl _fread_nolock_s(void *_DstBuf,size_t _DstSize,size_t _ElementSize,size_t _Count,FILE *_File);
    |                          ^
`gcc.exe' failed in phase `C Compiler'. (Exit code: 1)

Error: [S-6374]
       While building simple Setup.hs (scroll up to its section to see the error) using:
       C:\Users\Quarks\AppData\Local\Programs\stack\x86_64-windows\ghc-9.2.7\bin\ghc-9.2.7.exe -rtsopts -threaded -clear-package-db -global-package-db -hide-all-packages -package base -main-is StackSetupShim.mainOverride -package Cabal-3.6.3.0 C:\sr\setup-exe-src\setup-sDt42OhJ.hs C:\sr\setup-exe-src\setup-shim-sDt42OhJ.hs -o C:\sr\setup-exe-cache\x86_64-windows\tmp-Cabal-simple_sDt42OhJ_3.6.3.0_ghc-9.2.7.exe
       Process exited with code: ExitFailure 1
 Quarks   hello-world          |
819 |   _CRTIMP size_t __cdecl _fread_nolock_s(void *_DstBuf,size_t _DstSize,size_t _ElementSize,size_t _Count,FILE *_File);
    |                          ^
`gcc.exe' failed in phase `C Compiler'. (Exit code: 1)

Error: [S-6374]
       While building simple Setup.hs (scroll up to its section to see the error) using:
       C:\Users\Quarks\AppData\Local\Programs\stack\x86_64-windows\ghc-9.2.7\bin\ghc-9.2.7.exe -rtsopts -threaded -clear-package-db -global-package-db -hide-all-packages -package base -main-is StackSetupShim.mainOverride -package Cabal-3.6.3.0 C:\sr\setup-exe-src\setup-sDt42OhJ.hs C:\sr\setup-exe-src\setup-shim-sDt42OhJ.hs -o C:\sr\setup-exe-cache\x86_64-windows\tmp-Cabal-simple_sDt42OhJ_3.6.3.0_ghc-9.2.7.exe
       Process exited with code: ExitFailure 1
quarks
  • 33,478
  • 73
  • 290
  • 513
  • 1
    I looks like a problem with the C compiler. Which version are you using? – lsmor Apr 17 '23 at 15:17
  • realgcc.exe (Rev3, Built by MSYS2 project) 10.2.0 – quarks Apr 17 '23 at 15:34
  • 1
    does `ghc` works on its own? so `ghc hello-world.hs` should generate a file called `hello-world.exe` – lsmor Apr 17 '23 at 16:44
  • It throws the same error when I build using `ghc` directly – quarks Apr 17 '23 at 17:16
  • 1
    First time I see that error. Does [this](https://stackoverflow.com/a/50419101/9271266) help? Also consider using `ghcup` to manage your haskell distribution, as it is the most convenient method as in 2023 – lsmor Apr 18 '23 at 06:45

0 Answers0