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

Unable to load package `apecs-physics-0.4.5' #82

Open
montetzouma opened this issue Aug 21, 2021 · 20 comments
Open

Unable to load package `apecs-physics-0.4.5' #82

montetzouma opened this issue Aug 21, 2021 · 20 comments

Comments

@montetzouma
Copy link

I cloned the apecs project and tried to build it with stack, so that I can try the shmup example.
However, stack build came up with the following error.
Is this an actual issue or am I doing something wrong?
Thanks!

C:\apecs>stack build
Building all executables for `examples' once. After a successful build of all of them, only specified executables will be rebuilt.
examples> build (exe)
examples> Preprocessing executable 'constraints' for examples-0.1.0.0..
examples> Building executable 'constraints' for examples-0.1.0.0..
examples> [1 of 1] Compiling Main
examples> ghc.exe: unable to load package `apecs-physics-0.4.5'
examples> ghc.exe:  | C:\apecs\.stack-work\install\daa122fe\lib\x86_64-windows-ghc-8.6.5\apecs-physics-0.4.5-8viuxTPOf3sKmCxD9w6vQN\HSapecs-physics-0.4.5-8viuxTPOf3sKmCxD9w6vQN.o: unknown symbol `pthread_cond_wait'

--  While building package examples-0.1.0.0 (scroll up to its section to see the error) using:
      C:\sr\setup-exe-cache\x86_64-windows\Cabal-simple_Z6RU0evB_2.4.0.1_ghc-8.6.5.exe --builddir=.stack-work\dist\e626a42b build exe:constraints exe:helloworld exe:shmup exe:simple exe:tumbler --ghc-options " -fdiagnostics-color=always"
    Process exited with code: ExitFailure 1
@jonascarpay
Copy link
Owner

Judging from the error, it looks like it has trouble compiling the C dependencies of the physics engine. I have never compiled apecs-phsyics on Windows, and I'm not sure what's going on or how to go about fixing it.

Luckily for you, you don't need apecs-physics at all for the shmup example. You should be able to build just that executable with stack build examples:shmup, can you confirm if that works?

@montetzouma
Copy link
Author

Thanks for helping. I tried stack build examples:shmup but it comes up with the same error message I'm afraid. It might be a general problem of apecs (on Windows?) as I tried building the following project and it generated the same error as well.
Unity Tutorial Project in Haskell with Apecs and SDL2

@jonascarpay
Copy link
Owner

Strange, maybe stack doesn't know not to build other dependencies when building just 1 executable. Does stack build examples:simple work? Does stack build apecs work?

@montetzouma
Copy link
Author

  • stack build apecs did not produce any message, good or bad. I believe it was already built in one of my previous attempts.
  • stack build examples:simple produced the same error regarding apecs-physics.

@jonascarpay
Copy link
Owner

I think a temporary workaround could be to just delete all executables that rely on apecs-physics from examples.cabal. That is, delete all lines from 35 to the end of file, and try building the executables again.

@montetzouma
Copy link
Author

I'm afraid it's the same error even after deleting the lines from examples.cabal.
I also tried creating a new stack project with only the code from shmup in its Main and listing as dependencies only apecs, apecs-gloss, linear and random but it came up with the same error.
Perhaps then the apecs library itself depends on apecs-physics? Or there is a way to manually install the C dependencies of apecs-physics (presumably Chipmunk?) to circumvent this error?

@jonascarpay
Copy link
Owner

Ohhhhhhhh I realize what it is now, I forgot that apecs-gloss depends on apecs-physics...

The options for fixing this are

  1. fixing the windows build of apecs-physics,
  2. splitting out the physics parts of apecs-gloss into a separate package, and
  3. adding a build flag to apecs-gloss to build without the physics parts.

Option 1 is obviously nicest, but I don't have a windows dev environment to try and reproduce on. I'll have a think about whether I prefer 2 or 3.

Just to be sure though, can you make sure that you can build the gloss package on windows?

@dpwiz
Copy link
Collaborator

dpwiz commented Aug 23, 2021

Strange. I've certainly built projects with apecs-gloss on windows with stack.

@montetzouma
Copy link
Author

I can confirm that gloss builds fine on Windows.
@jonascarpay thanks for helping! Let me know if you decide to implement either 2 or 3 (although after @dpwiz 's comment the issue might be different?). I'm not experienced with these kind of things but I'm happy to help with implementing 1 if you decide to try that.

@jonascarpay
Copy link
Owner

@dpwiz Hmm, thanks for the input. When you built it, was that as a dependency, or from the apecs project folder? This project is still on LTS 13, so maybe it's just a GHC version issue.
@montetzouma, can you try building with --resolver=lts-18?

@montetzouma
Copy link
Author

It gives the same error with stack build --resolver=lts-18.
Mind you, I had to add the following extra dependencies (suggested by stack) in stack.yaml otherwise the build was failing.

extra-deps:
  - directory-1.3.6.2@sha256:6e5f3e0adfe94483d5754d97d741b7d23a5e085d47176075b1955d4fa78f37aa,2811
  - time-1.10@sha256:536801b30aa2ce66da07cb19847827662650907efb2af4c8bef0a6276445075f,5738
  - process-1.6.13.2@sha256:9733aa8a27b3e6c0f08a87a5c7287b3b73302d396f68f5655f9990a641368e3e,2845
  - Cabal-3.2.1.0@sha256:8743076ec022296f9771d962000c9ca3a0fe02e68c37b992c63e382a675f791d,27482

@dpwiz
Copy link
Collaborator

dpwiz commented Aug 24, 2021

I've tested my game and the latest lts-18 is broken*, while lts-18.5 builds and runs all right.

*Something to do with GHC internal packages.

@dpwiz
Copy link
Collaborator

dpwiz commented Aug 24, 2021

This looks like it
commercialhaskell/stackage#6176

@montetzouma
Copy link
Author

montetzouma commented Aug 25, 2021

Unfortunately, both stack build --resolver=lts-18.5 and stack build examples:shmup --resolver=lts-18.5 fail with the same error as above for me.
@dpwiz maybe your game uses gloss or sdl instead of apecs-gloss?
I attach the full build log in case it is helpful.
build.log

@dpwiz
Copy link
Collaborator

dpwiz commented Aug 25, 2021

Definitely apecs-gloss (:

You can try building it too, but I'd expect the result will be the same: https://gitlab.com/dpwiz/spacemar

@montetzouma
Copy link
Author

@dpwiz I have successfully built and run spacemar with stack! This probably means that I have been doing something wrong with shmup or there is a workaround for solving the issue. I will try to look into your code over the next couple of days and see what differences I can spot. Thanks for providing your project!

@montetzouma
Copy link
Author

The problem appears to be with apecs-physics-0.4.5.
Adding

extra-deps:
  - apecs-physics-0.4.4

in stack.yaml (as @dpwiz had in his game) fixes the issue and everything runs fine.
Thanks everyone for your help!
@jonascarpay Let me know if I can help in some way with fixing this :)

@jonascarpay
Copy link
Owner

@montetzouma Glad you found a workaround.

So, apecs-physics 0.4.5 broke the Windows build. 0.4.5 was about bumping Chipmunk2D from 7.0.2 to 7.0.3, in response to issues with the linux build, the exact changes for which can be found here. I don't immediately see how those changes could cause it not to find pthread_cond_wait, but it might be related to slembcke/Chipmunk2D#194 since they're both about linking error related to cpHastySpace.c.

I don't know if this issue is with GHC, Chipmunk, Cabal, or apecs-physics, and I'm not really in a position to investigate it myself. For now, I'll leave this issue open so that people with the same issue will at least find your workaround. It is unfortunate though, so if anybody is able to better investigate that would be very welcome.

@dpwiz Can I add a link to your game in the project README?

@dpwiz
Copy link
Collaborator

dpwiz commented Aug 27, 2021

@jonascarpay I'd be honored (:

@dpwiz
Copy link
Collaborator

dpwiz commented Mar 8, 2023

There's some kind of fix mentioned in 194.

If it works, it would be possible to graft it on a vendored copy while waiting for upstream.

https://github.com/slembcke/Chipmunk2D/pull/229/files

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants