Skip to content

macOS install not using brew installed libraries #439

@MyztikJenz

Description

@MyztikJenz

Let me start off with saying I'm trying to get MPF to run on an older build of macOS: 10.15.7. The hardware is older (Late 2012 Mac mini) and is not going to benefit from a newer OS. And I know this is going to be more challenging (I've already fought through some brew issues).

That said, I find myself with a problem that presents itself as the following after installing all the necessary bits. When running the mc_demo machine, I get this error:

  File "/Users/pinball/.local/pipx/venvs/mpf/lib/python3.9/site-packages/mpfmc/assets/bitmap_font.py", line 3, in <module>
    from mpfmc.uix.bitmap_font.bitmap_font import BitmapFont
ImportError: dlopen(/Users/pinball/.local/pipx/venvs/mpf/lib/python3.9/site-packages/mpfmc/uix/bitmap_font/bitmap_font.cpython-39-darwin.so, 2): Symbol not found: _kIOMainPortDefault
  Referenced from: /Users/pinball/.local/pipx/venvs/mpf/lib/python3.9/site-packages/mpfmc/uix/bitmap_font/../../.dylibs/libSDL2-2.0.0.dylib (which was built for Mac OS X 12.0)
  Expected in: /System/Library/Frameworks/IOKit.framework/Versions/A/IOKit

Poking at /Users/pinball/.local/pipx/venvs/mpf/lib/python3.9/site-packages/mpfmc/uix/bitmap_font/../../.dylibs/libSDL2-2.0.0.dylib I indeed see it has a reference to _kIOMainPortDefault:

Pinballs-Mini:~ pinball$ nm /Users/pinball/.local/pipx/venvs/mpf/lib/python3.9/site-packages/mpfmc/uix/bitmap_font/../../.dylibs/libSDL2-2.0.0.dylib | grep -i portdefault
                 U _kIOMainPortDefault

This might be the core of the problem... 10.15's IOKit doesn't seem to have a kIOMainPortDefault, only Master:

Pinballs-Mini:mc_demo pinball$ nm /System/Library/Frameworks/IOKit.framework/Versions/A/IOKit | grep -i portdefault
000000000009cb20 S _kIOMasterPortDefault

But I'm curious why bitmap_font chose to use this dylib at all, when libSDL2 is installed already:

Pinballs-Mini:~ pinball$ brew list sdl2
/usr/local/Cellar/sdl2/2.26.2/bin/sdl2-config
/usr/local/Cellar/sdl2/2.26.2/include/SDL2/ (78 files)
/usr/local/Cellar/sdl2/2.26.2/lib/libSDL2-2.0.0.dylib
/usr/local/Cellar/sdl2/2.26.2/lib/cmake/ (2 files)
/usr/local/Cellar/sdl2/2.26.2/lib/pkgconfig/sdl2.pc
/usr/local/Cellar/sdl2/2.26.2/lib/ (4 other files)
/usr/local/Cellar/sdl2/2.26.2/share/aclocal/sdl2.m4

and seemed to have noticed the symbol issue and used the right one:

Pinballs-Mini:~ pinball$ nm /usr/local/Cellar/sdl2/2.26.2/lib/libSDL2-2.0.0.dylib | grep -i portdefault
                 U _kIOMasterPortDefault

If I symlink brew's version of the dylib into the .dylibs folder bitmap_font is looking at, it gets past this error (and onto another missing symbol in a different library). The core of my problem seems to be that mpf-mc wants to use its own dylibs when legit ones are already installed. I went looking for the logic that determines how it chooses which to use but pip install packages are a dark art I don't understand.

Is there a way to force mpf-mc to use brew's library install instead of the shared libs that it comes with? It seems to have this capacity, I have MPF installed on an M1 Mac running macOS 13 and it installed mpf-mc using the brew installed components:

bash-3.2$ otool -L  bitmap_font.cpython-39-darwin.so 
bitmap_font.cpython-39-darwin.so (architecture x86_64):
        /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1311.100.3)
bitmap_font.cpython-39-darwin.so (architecture arm64):
        /opt/homebrew/opt/sdl2/lib/libSDL2-2.0.0.dylib (compatibility version 2401.0.0, current version 2401.0.0)
        /opt/homebrew/opt/sdl2_image/lib/libSDL2_image-2.0.0.dylib (compatibility version 601.0.0, current version 601.2.0)
        /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1311.100.3)

Thanks for reading this far!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions