_g_content_type_get_mime_dirs missing from libgio-2.0.0.dylib on MacOS
Brief Intro
As the title mentions, my libgio-2.0.0.dylib seems to be missing a symbol called g_content_type_get_mime_dirs.
Background
I am trying to use Haskell's gi-gtk. gi-gtk seems to result in a Haskell dylib called libHSgi-gio-2.0.19-7OCgNZnEEEh4XbhFBPrEBZ-ghc8.6.4.dylib being added to my system. When I try to build my project using stack, I get the following error message:
<command line>: can't load .so/.DLL for: /Users/sam/.stack/snapshots/x86_64-osx/lts-13.19/8.6.4/lib/x86_64-osx-ghc-8.6.4/libHSgi-gio-2.0.19-7OCgNZnEEEh4XbhFBPrEBZ-ghc8.6.4.dylib (dlopen(/Users/sam/.stack/snapshots/x86_64-osx/lts-13.19/8.6.4/lib/x86_64-osx-ghc-8.6.4/libHSgi-gio-2.0.19-7OCgNZnEEEh4XbhFBPrEBZ-ghc8.6.4.dylib, 5): Symbol not found: _g_content_type_get_mime_dirs
Referenced from: /Users/sam/.stack/snapshots/x86_64-osx/lts-13.19/8.6.4/lib/x86_64-osx-ghc-8.6.4/libHSgi-gio-2.0.19-7OCgNZnEEEh4XbhFBPrEBZ-ghc8.6.4.dylib
Investigation
The error message in the previous section is probably a little bit stupid since nowhere is libgio actually mentioned. Since I can run nm /Users/sam/.stack/snapshots/x86_64-osx/lts-13.19/8.6.4/lib/x86_64-osx-ghc-8.6.4/libHSgi-gio-2.0.19-7OCgNZnEEEh4XbhFBPrEBZ-ghc8.6.4.dylib | grep _g_content_type_get_mime_dirs
which shows that this dylib actually contains _g_content_type_get_mime_dirs.
However when I run otool -L /Users/sam/.stack/snapshots/x86_64-osx/lts-13.19/8.6.4/lib/x86_64-osx-ghc-8.6.4/libHSgi-gio-2.0.19-7OCgNZnEEEh4XbhFBPrEBZ-ghc8.6.4.dylib
to list the dependencies of the Haskell dylib I get the following output:
/Users/sam/.stack/snapshots/x86_64-osx/lts-13.19/8.6.4/lib/x86_64-osx-ghc-8.6.4/libHSgi-gio-2.0.19-7OCgNZnEEEh4XbhFBPrEBZ-ghc8.6.4.dylib:
@rpath/libHSgi-gio-2.0.19-7OCgNZnEEEh4XbhFBPrEBZ-ghc8.6.4.dylib (compatibility version 0.0.0, current version 0.0.0)
/usr/local/opt/glib/lib/libgio-2.0.0.dylib (compatibility version 6001.0.0, current version 6001.3.0)
@rpath/libHSgi-gobject-2.0.16-7ET5iZxEieTIXsIa6BW1PD-ghc8.6.4.dylib (compatibility version 0.0.0, current version 0.0.0)
@rpath/libHSgi-glib-2.0.17-3Rarfp1IZWoD48pfd25lc7-ghc8.6.4.dylib (compatibility version 0.0.0, current version 0.0.0)
@rpath/libHShaskell-gi-base-0.21.5-B7L3HQFSPkOFeLcsLCK63O-ghc8.6.4.dylib (compatibility version 0.0.0, current version 0.0.0)
@rpath/libHStext-1.2.3.1-ghc8.6.4.dylib (compatibility version 0.0.0, current version 0.0.0)
@rpath/libHSbytestring-0.10.8.2-ghc8.6.4.dylib (compatibility version 0.0.0, current version 0.0.0)
@rpath/libHSbase-4.12.0.0-ghc8.6.4.dylib (compatibility version 0.0.0, current version 0.0.0)
@rpath/libHSinteger-gmp-1.0.2.0-ghc8.6.4.dylib (compatibility version 0.0.0, current version 0.0.0)
@rpath/libHSghc-prim-0.5.3-ghc8.6.4.dylib (compatibility version 0.0.0, current version 0.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.250.1)
So we can see that this dylib depends on /usr/local/opt/glib/lib/libgio-2.0.0.dylib. I confess I don't know who or what installed glib to /usr/local/opt/glib since I also installed glib through homebrew which made it go to /usr/local/Cellar/glib. I also don't know what made this haskell dylib choose to refer to /usr/local/opt over /usr/local/Cellar. Anyway, I checked both of these files and they are both missing the _g_content_type_get_mime_dirs symbol.
I discussed with one of the maintainers of the haskell-gi project over here: https://github.com/haskell-gi/haskell-gi/issues/227 and he advised me to check whether my Gio-2.0.gir files contain a reference to _g_content_type_get_mime_dirs in which case he said this looks like an upstream bug. One interesting thing he pointed out was that there seems to be an OSX-specific gosxcontenttype.m file which does not define the missing symbol I am seeing. I assumed upstream means glib in this case, so here I am.
Questions and Insights
- The symbol is sometimes prefixed with an underscore, might be significant? Anyway I tried to
grep
without the underscore to not get any false negatives - Any idea why my MacOS system has glib installed in /usr/local/opt/glib, is this the default for MacOS?
- I checked all the symbols prefixed with g_content_type in both the haskell libHSgi-gio dylib as well as the libgio-2.0.0.dylib and found that the two function symbols that were missing from libgio were marked as
/*< private >*/
in the C source for that file. Could this have any relevance?
Sorry for the long post, but hope you can point me in the right direction to having gi-gtk work on MacOS.