Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does not seem to work under Windows #14

Closed
bjornkihlberg opened this issue Mar 25, 2023 · 3 comments
Closed

Does not seem to work under Windows #14

bjornkihlberg opened this issue Mar 25, 2023 · 3 comments
Labels
bug Something isn't working windows Problems with the bindings on windows

Comments

@bjornkihlberg
Copy link

Hello,

When I run the following program with cabal run under Windows nothing happens.

hello-raylib> cabal run
hello-raylib>

hello-raylib.cabal

cabal-version:      3.4
name:               hello-raylib
version:            0.1.0.0

common warnings
    ghc-options: -Wall

executable hello-raylib
    import:             warnings
    main-is:            Main.hs
    build-depends:      base ^>=4.16.0.0
                      , h-raylib
    hs-source-dirs:     app
    default-language:   Haskell2010

app/Main.hs

module Main where

import Control.Monad (unless)
import qualified Raylib.Core as Raylib

main :: IO ()
main = do
  w <- Raylib.initWindow 480 320 "Hello, Raylib!"
  let loop = do
        shouldClose <- Raylib.windowShouldClose
        unless shouldClose loop
  loop
  Raylib.closeWindow w

I tried updating my NVidia drivers. No change.
I installed raylib and successfully ran one of their examples in C so I suspect there's something wrong with this package or something I've done or missed in the code posted above.

Thank you and kind regards
Björn

@bjornkihlberg
Copy link
Author

bjornkihlberg commented Mar 25, 2023

I tried running hello-raylib.exe inside dist-newstyle/build/x86_64-windows/ghc-9.2.1/hello-raylib-0.1.0.0/x/hello-raylib/\build/hello-raylib/ directly and I got this.
image
So it says (writing this for poor souls using a search engine)

The code execution cannot proceed because libwinpthread-1.dll was not found. Reinstalling the program may fix this problem.

which is a clue.

@bjornkihlberg
Copy link
Author

bjornkihlberg commented Mar 25, 2023

I got it to work with this solution.

The issue is that libwinpthread-1.dll is not available on the PATH when trying to run your raylib application. It looks like Windows users using Nim had the same problem.

Here are the steps I did explicitly:

  1. I use ghcup which keeps msys2 in its installation folder so I added C:\ghcup\msys64 to my PATH which allows me to open the msys2 executable. I don't think this is strictly needed but I did it so I'm writing it down here.
  2. I also added C:\ghcup\msys64\mingw64\bin which is actually needed for raylib to work.
  3. Then I ran msys2 and in it's shell ran this command
    $ pacman -Syu
    
    which updates the current libraries. After it's done it wants to shut down the shell. Accept and start it up again.
  4. Then I ran these commands
    $ pacman -S msys2-keyring
    $ pacman -Syu
    $ pacman -S base-devel mingw-w64-x86_64-toolchain
    
    I had issues with some PGP signatures so I had to install msys2-keyring and then run another system update to make them work. Note that I didn't need to restart the shell this time!
  5. I exited out of the shell and cabal run worked.

My program behaved funny but it wasn't the fault of raylib. It was because I didn't invoke beginDrawing and endDrawing which I assume polls the window for events.

Anyway, I though I'd leave this here in case anyone else runs into this.

@Anut-py
Copy link
Owner

Anut-py commented Mar 25, 2023

Great, I'm glad you could find a solution! I'll add a link to this in the readme.

@Anut-py Anut-py closed this as completed Mar 25, 2023
@Anut-py Anut-py added bug Something isn't working windows Problems with the bindings on windows labels Jan 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working windows Problems with the bindings on windows
Projects
None yet
Development

No branches or pull requests

2 participants