greenfork / nimraylib_now

The Ultimate Raylib gaming library wrapper for Nim
MIT License
149 stars 16 forks source link

Windows System Error can't find libwinpthread-1.dll #66

Open creikey opened 2 years ago

creikey commented 2 years ago

After following the readme and doing

nimble install nimraylib_now

Then trying to run a nim file with just

import nimraylib_now

in it With

nim c -r -d:release --gc:orc crown.nim

I get this error: image

greenfork commented 2 years ago

Hi, I think you can take a look at Troubleshooting section of readme https://github.com/greenfork/nimraylib_now#windows-error-the-application-was-unable-to-start-correctly-0x00000007b

milanbt commented 2 years ago

I'm having this problem too. Even after adding C:\Program Files\nim-1.6.2\dist\mingw64\bin to path, I still get "Windows error: The application was unable to start correctly (0x00000007b)" on other windows machines, although it ran on the one with mingw installed. I tried installing and setting path for mingw installed via msys with the same result. I'm on Windows 11.

creikey commented 2 years ago

Why does raylib need pthreads?

creikey commented 2 years ago

image

Maybe statically link like this?

milanbt commented 2 years ago

So I tried with nim c -r -d:release --gc:orc --app:gui --passC:"-static" main.nim It still didn't work, but now there is no error message when the dll is in the same folder and the same missing message without it.

milanbt commented 2 years ago

I tried compiling on a Windows 10 machine where I installed using choosenim. I think on the 11 I installed the binary on the nim website (it's installed in Program Files). Now it runs when I have libwinpthread-1.dll in the same directory on another Windows 10 computer and also the Windows 11 computer after removing libwinpthread-1.dll from the mingw\bin directory so it can't use that one.

Also, adding mingw\bin to the system path, rebooting, recompiling with --passC:"-static" --passL:"-lpthread", and running again on a different Windows 10 machine did not allow me to run without the libwinpthread-1.dll in the directory.

greenfork commented 2 years ago

Also, adding mingw\bin to the system path, rebooting, recompiling with --passC:"-static" --passL:"-lpthread", and running again on a different Windows 10 machine did not allow me to run without the libwinpthread-1.dll in the directory.

This is still connected to the wrong paths since the problem is not with the library but with Windows being unable to properly locate it. It is a hard sign that something is wrong with the paths.

Even after adding C:\Program Files\nim-1.6.2\dist\mingw64\bin to path

This successfully resolved the problem for this issue https://github.com/greenfork/nimraylib_now/issues/2. I'm not sure what's wrong in your case.

Why does raylib need pthreads?

Raylib requires pthreads for some functionality. So linking is enabled by default for NimraylibNow. Disabling it by default won't solve the problem because once you need it, you will be in the same situation.

Overall, if you can find a recipe of what we need to change to make it work out of the box, we can add it to the library. But that being said, my understanding is that a lot of people use this library on Windows and they don't have these problems or they successfully solve them.

I will leave this issue open for some time so people can help. I think that we need to add some instruction on how to properly add the PATH to Windows to make it work. Or just to plainly copy the .dll since you will still have to distribute this game. Or maybe we can add some link step which will correctly detect the location of this .dll and link it on any Windows machine.

milanbt commented 2 years ago

I think it might be specific to compiling on Windows 11, since it worked when I compiled on Windows 10 (albeit only with the .dll in the directory)

creikey commented 2 years ago

My issues were with Windows 11 as well

greenfork commented 2 years ago

So far this is the best option: bundle libwinpthread-1.dll together with the exe which is located in C:\Program Files\nim-1.6.2\dist\mingw64\bin for default installation of Nim v1.6.2.

Now it runs when I have libwinpthread-1.dll in the same directory on another Windows 10 computer and also the Windows 11 computer after removing libwinpthread-1.dll from the mingw\bin directory so it can't use that one.

enthus1ast commented 2 years ago

It would be interesting to know where the library is searched. Can you check with strace? (In the git for windows installation or some tool mentioned here: https://stackoverflow.com/questions/3847745/systrace-for-windows ) then it would be much easier to track down the issue.

greenfork commented 2 years ago

@creikey @milanbt there's a possible solution in the PR, do you have time to check if that works for you?