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

gossip with ffmpeg support builds new libSDL2 when it exists already in homebrew #3

Open
badonyx opened this issue Aug 30, 2023 · 7 comments

Comments

@badonyx
Copy link
Collaborator

badonyx commented Aug 30, 2023

gossip is building its own libSDL2 and leaves linking ambiguous. ideally it would just use the existing SDL2 from homebrew.

❯ gossip
objc[86459]: Class SDL_RumbleMotor is implemented in both /opt/homebrew/Cellar/sdl2/2.28.2/lib/libSDL2-2.0.0.dylib (0x10c5dccd8) and /opt/homebrew/Cellar/gossip/HEAD-3ff7bdc/libexec/libSDL2-2.0.0.dylib (0x107458820). One of the two will be used. Which one is undefined.
objc[86459]: Class SDL_RumbleContext is implemented in both /opt/homebrew/Cellar/sdl2/2.28.2/lib/libSDL2-2.0.0.dylib (0x10c5dcd28) and /opt/homebrew/Cellar/gossip/HEAD-3ff7bdc/libexec/libSDL2-2.0.0.dylib (0x107458870). One of the two will be used. Which one is undefined.
objc[86459]: Class SDLApplication is implemented in both /opt/homebrew/Cellar/sdl2/2.28.2/lib/libSDL2-2.0.0.dylib (0x10c5dc828) and /opt/homebrew/Cellar/gossip/HEAD-3ff7bdc/libexec/libSDL2-2.0.0.dylib (0x1074588c0). One of the two will be used. Which one is undefined.
objc[86459]: Class SDLAppDelegate is implemented in both /opt/homebrew/Cellar/sdl2/2.28.2/lib/libSDL2-2.0.0.dylib (0x10c5dc878) and /opt/homebrew/Cellar/gossip/HEAD-3ff7bdc/libexec/libSDL2-2.0.0.dylib (0x107458910). One of the two will be used. Which one is undefined.
objc[86459]: Class SDLTranslatorResponder is implemented in both /opt/homebrew/Cellar/sdl2/2.28.2/lib/libSDL2-2.0.0.dylib (0x10c5dc8f0) and /opt/homebrew/Cellar/gossip/HEAD-3ff7bdc/libexec/libSDL2-2.0.0.dylib (0x107458988). One of the two will be used. Which one is undefined.
objc[86459]: Class SDLMessageBoxPresenter is implemented in both /opt/homebrew/Cellar/sdl2/2.28.2/lib/libSDL2-2.0.0.dylib (0x10c5dc918) and /opt/homebrew/Cellar/gossip/HEAD-3ff7bdc/libexec/libSDL2-2.0.0.dylib (0x1074589b0). One of the two will be used. Which one is undefined.
objc[86459]: Class SDL_cocoametalview is implemented in both /opt/homebrew/Cellar/sdl2/2.28.2/lib/libSDL2-2.0.0.dylib (0x10c5dc968) and /opt/homebrew/Cellar/gossip/HEAD-3ff7bdc/libexec/libSDL2-2.0.0.dylib (0x107458a00). One of the two will be used. Which one is undefined.
objc[86459]: Class SDLOpenGLContext is implemented in both /opt/homebrew/Cellar/sdl2/2.28.2/lib/libSDL2-2.0.0.dylib (0x10c5dc9b8) and /opt/homebrew/Cellar/gossip/HEAD-3ff7bdc/libexec/libSDL2-2.0.0.dylib (0x107458a50). One of the two will be used. Which one is undefined.
objc[86459]: Class SDL_ShapeData is implemented in both /opt/homebrew/Cellar/sdl2/2.28.2/lib/libSDL2-2.0.0.dylib (0x10c5dca30) and /opt/homebrew/Cellar/gossip/HEAD-3ff7bdc/libexec/libSDL2-2.0.0.dylib (0x107458ac8). One of the two will be used. Which one is undefined.
objc[86459]: Class SDL_CocoaClosure is implemented in both /opt/homebrew/Cellar/sdl2/2.28.2/lib/libSDL2-2.0.0.dylib (0x10c5dca80) and /opt/homebrew/Cellar/gossip/HEAD-3ff7bdc/libexec/libSDL2-2.0.0.dylib (0x107458b18). One of the two will be used. Which one is undefined.
objc[86459]: Class SDL_VideoData is implemented in both /opt/homebrew/Cellar/sdl2/2.28.2/lib/libSDL2-2.0.0.dylib (0x10c5dcad0) and /opt/homebrew/Cellar/gossip/HEAD-3ff7bdc/libexec/libSDL2-2.0.0.dylib (0x107458b68). One of the two will be used. Which one is undefined.
objc[86459]: Class SDL_WindowData is implemented in both /opt/homebrew/Cellar/sdl2/2.28.2/lib/libSDL2-2.0.0.dylib (0x10c5dcb20) and /opt/homebrew/Cellar/gossip/HEAD-3ff7bdc/libexec/libSDL2-2.0.0.dylib (0x107458bb8). One of the two will be used. Which one is undefined.
objc[86459]: Class SDLWindow is implemented in both /opt/homebrew/Cellar/sdl2/2.28.2/lib/libSDL2-2.0.0.dylib (0x10c5dcb48) and /opt/homebrew/Cellar/gossip/HEAD-3ff7bdc/libexec/libSDL2-2.0.0.dylib (0x107458be0). One of the two will be used. Which one is undefined.
objc[86459]: Class Cocoa_WindowListener is implemented in both /opt/homebrew/Cellar/sdl2/2.28.2/lib/libSDL2-2.0.0.dylib (0x10c5dcb70) and /opt/homebrew/Cellar/gossip/HEAD-3ff7bdc/libexec/libSDL2-2.0.0.dylib (0x107458c08). One of the two will be used. Which one is undefined.
objc[86459]: Class SDLView is implemented in both /opt/homebrew/Cellar/sdl2/2.28.2/lib/libSDL2-2.0.0.dylib (0x10c5dcbe8) and /opt/homebrew/Cellar/gossip/HEAD-3ff7bdc/libexec/libSDL2-2.0.0.dylib (0x107458c80). One of the two will be used. Which one is undefined.
objc[86459]: Class METAL_RenderData is implemented in both /opt/homebrew/Cellar/sdl2/2.28.2/lib/libSDL2-2.0.0.dylib (0x10c5dcc60) and /opt/homebrew/Cellar/gossip/HEAD-3ff7bdc/libexec/libSDL2-2.0.0.dylib (0x107458cf8). One of the two will be used. Which one is undefined.
objc[86459]: Class METAL_TextureData is implemented in both /opt/homebrew/Cellar/sdl2/2.28.2/lib/libSDL2-2.0.0.dylib (0x10c5dccb0) and /opt/homebrew/Cellar/gossip/HEAD-3ff7bdc/libexec/libSDL2-2.0.0.dylib (0x107458d48). One of the two will be used. Which one is undefined.
2023-08-30T00:31:15.388719Z  INFO src/filter.rs:30: No spam filter: No such file or directory (os error 2)
...
❯ otool -L /opt/homebrew/Cellar/gossip/HEAD-3ff7bdc/bin/gossip
/opt/homebrew/Cellar/gossip/HEAD-3ff7bdc/bin/gossip:
        @rpath/libSDL2-2.0.0.dylib (compatibility version 2601.0.0, current version 2601.4.0)
        /opt/homebrew/opt/ffmpeg/lib/libavutil.58.dylib (compatibility version 58.0.0, current version 58.2.100)
        /opt/homebrew/opt/ffmpeg/lib/libavformat.60.dylib (compatibility version 60.0.0, current version 60.3.100)
        /opt/homebrew/opt/ffmpeg/lib/libavfilter.9.dylib (compatibility version 9.0.0, current version 9.3.100)
        /opt/homebrew/opt/ffmpeg/lib/libavdevice.60.dylib (compatibility version 60.0.0, current version 60.1.100)
        /opt/homebrew/opt/ffmpeg/lib/libswscale.7.dylib (compatibility version 7.0.0, current version 7.1.100)
        /opt/homebrew/opt/ffmpeg/lib/libswresample.4.dylib (compatibility version 4.0.0, current version 4.10.100)
        /opt/homebrew/opt/ffmpeg/lib/libavcodec.60.dylib (compatibility version 60.0.0, current version 60.3.100)
        /System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL (compatibility version 1.0.0, current version 1.0.0)
        /System/Library/Frameworks/CoreServices.framework/Versions/A/CoreServices (compatibility version 1.0.0, current version 1228.0.0)
        /System/Library/Frameworks/AppKit.framework/Versions/C/AppKit (compatibility version 45.0.0, current version 2299.50.120)
        /System/Library/Frameworks/Foundation.framework/Versions/C/Foundation (compatibility version 300.0.0, current version 1971.0.0)
        /System/Library/Frameworks/QuartzCore.framework/Versions/A/QuartzCore (compatibility version 1.2.0, current version 1.11.0)
        /usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 228.0.0)
        /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1319.100.3)
        /System/Library/Frameworks/ApplicationServices.framework/Versions/A/ApplicationServices (compatibility version 1.0.0, current version 61.0.0)
        /System/Library/Frameworks/CoreGraphics.framework/Versions/A/CoreGraphics (compatibility version 64.0.0, current version 1690.5.4)
        /System/Library/Frameworks/CoreVideo.framework/Versions/A/CoreVideo (compatibility version 1.2.0, current version 1.5.0)
        /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 1971.0.0)
        /System/Library/Frameworks/Security.framework/Versions/A/Security (compatibility version 1.0.0, current version 60420.101.2)
        /usr/lib/libiconv.2.dylib (compatibility version 7.0.0, current version 7.0.0)
        /System/Library/Frameworks/ColorSync.framework/Versions/A/ColorSync (compatibility version 1.0.0, current version 4.13.0)

When modifying the formula to not include the new libSDL2:

❯ gossip
dyld[83390]: Library not loaded: @rpath/libSDL2-2.0.0.dylib
  Referenced from: <72E4FA29-8A4E-3C73-BB4D-1E4D0D75B787> /opt/homebrew/Cellar/gossip/HEAD-3ff7bdc/bin/gossip
  Reason: tried: '/opt/homebrew/Cellar/gossip/HEAD-3ff7bdc/bin/libSDL2-2.0.0.dylib' (no such file), '/opt/homebrew/Cellar/gossip/HEAD-3ff7bdc/bin/libSDL2-2.0.0.dylib' (no such file), '/usr/local/lib/libSDL2-2.0.0.dylib' (no such file), '/usr/lib/libSDL2-2.0.0.dylib' (no such file, not in dyld cache)
zsh: abort      gossip

Possible solutions?

  • Link rpath to libexec?
  • Remove bundled feature for sdl2 crate?
@badonyx
Copy link
Collaborator Author

badonyx commented Aug 30, 2023

@mikedilger @jacany any idea how to fix this? I tried modifying CPPFLAGS and LDFLAGS like in the build_macos.sh packaging script with no resulting change in behavior.

ENV.prepend "CPPFLAGS", "-I#{HOMEBREW_PREFIX}/include"
ENV.prepend "LDFLAGS", "-L#{HOMEBREW_PREFIX}/lib -Wl,-rpath,#{HOMEBREW_PREFIX}/lib"

@mikedilger
Copy link

Building on MacOS is not my specialty. I do it for releases because people asked me to. But I haven't booted that machine for a few months. When I get time I'll try to compile it again over there, and to look also at @jacany 's gossip tap. I hope you guys can work out how gossip should be compiled on MacOS, and I'll follow on from that result.

@badonyx
Copy link
Collaborator Author

badonyx commented Sep 28, 2023

Fixed by using SDL2 crate feature use-pkgconfig instead of bundled. (only tested on macos.)
https://github.com/badonyx/gossip/tree/patch-sdl2-no-bundled
https://github.com/badonyx/egui-video/tree/patch-sdl2-no-bundled

That feature is not really necessary except maybe for Windows right?

@mikedilger
Copy link

Ok. I'll have to try it on the other platforms but it sounds right

@badonyx
Copy link
Collaborator Author

badonyx commented Sep 29, 2023

I had some issue building on linux with that patch. And I forgot about packaging stuff -- it should be bundled with the .app on macos but not when built with a package manager. Not really sure how to branch out all that logic with cargo. Maybe it's best leaving as is. It still runs even if it complains a bit.

@badonyx
Copy link
Collaborator Author

badonyx commented Sep 30, 2023

Can we somehow unlink from the system SDL2 library and only link to the bundled one?

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

2 participants