Two fontconfigs are mixed up -- what to do?

Hello,

I’m developing a library that uses among others libXft and harfbuzz. The latter was a recent addition and I noticed coredumps on macosx. The problem seems to be that libXft that comes with xquartz is linked against xquartz’s fontconfig v11 in /opt/X11, while harfbuzz picks up fontconfig from /usr/local during ‘brew install’, v14 (and correspondingly libfreetype, versions 14 vs 24)

I’m not sure what a solution would be here; I guess if I explicitly export PKG_CONFIG_PATH to be /opt/X11/lib/pkgconfig during ‘brew install harfbuzz’ then harfbuzz might be linked correctly. However I still don’t understand what was the rationale to allow brew to build a separate set of fontconfig and freetype, creating a linkage conflict.

How to configure my library in that situation? If I let my ./configure script to run as is, it will complain that -lXft is not found. If I either let the user set PKG_CONFIG_PATH or discover it automatically, then harfbuzz will crash as Xft is initialized first and will pull its own fontconfig in.

Any advice appreciated!
Thank you

There’s no rationale, because XQuartz (like all cask-deployed software) is not built by Homebrew. The cask mechanism simply automates the installation of third-party macOS binary packages, and since XQuartz was last released in late 2016, the writing is firmly etched on the X11-on-macOS wall. This is why, as Sean Molenaar observed in a related thread, almost nothing in homebrew-core uses X11.

Since your library absolutely requires X11, you may well have to explicitly build harfbuzz against deployed XQuartz, then deploy that xquartz-harfbuzz library in your own tap.

Thank you! It’s a bit clearer now.

So indeed I made my own tap, but for libXft instead, so it can be reused by whoever ends in that situation:

 brew install dk/x11/xorg-macros
 brew install dk/x11/libxft

The thread you mentioned had someone wanting libX11, probably expanding this repo in such a way that it contains all the X11 libs – xrender, xext, etc etc – would make sense? Could that be a good idea to add this tap to the homebrew list of taps, for that reason?

Anyway this approach resolves the problem for me, hopefully it will for someone else, too

If you mean getting a libx11 formula added to the core tap, and thereby opening the floodgates to Homebrew X11 apps, I think it’s safe to say that’s not gonna happen. X11 apps built with current libraries might work with ancient XQuartz, or might not, or might cause XQuartz to do something nasty to your system. I’m pretty sure the Homebrew maintainers will frown heavily on that.