Solvedbrew pkg-config files on >=10.14 assume headers in /usr/include
✔️Accepted Answer
Looks like there's a significant issue with the way SwiftPM handles pkg-config. It incorrectly handles *.pc files directly so that PKG_CONFIG_SYSTEM_INCLUDE_PATH
(be it the environment variable or the baked in default) is not appropriately applied. It attempts to mimic what pkg-config does but this implementation is incomplete: https://github.com/apple/swift-package-manager/blob/d433df8bfca5e3df498b3300c2b6aee222154cd4/Sources/PackageLoading/Target%2BPkgConfig.swift#L244
The SwiftPM issue has fatal effects on macOS due to systems headers no longer being at /usr/include
since Mojave (SwiftPM only filters /usr/include
still).
This isn't however something macOS specific. There are multiarch Linux distros that rely on this. There's also other variables commonly used in places on Linux like PKG_CONFIG_ALLOW_SYSTEM_LIBS
. SwiftPM fails to recognise any of this.
There is a general issue covering the topic at https://bugs.swift.org/browse/SR-6317, filed internally as rdar://problem/40235197.
I'll look into deleting cflags
entirely until the Swift issue is fixed.
Other Answers:
Hi folks, it looks like this also broke building Go packages that depend on pkg-config for CGO dependencies.
Some sample output from a Go project:
❯ go test ./... # /usr/local/Homebrew/Library/Homebrew/shims/mac/super/pkg-config --cflags -- opus opus opus opusfile opus opusfile /usr/local/Homebrew/Library/Homebrew/shims/mac/super/pkg-config: line 6: /pkg-config/bin/pkg-config: No such file or directory /usr/local/Homebrew/Library/Homebrew/shims/mac/super/pkg-config: line 6: exec: /pkg-config/bin/pkg-config: cannot execute: No such file or directory /usr/local/Homebrew/Library/Homebrew/shims/mac/super/pkg-config: exit status 126Looks like
HOMEBREW_OPT
isn’t set. I’d love to help—how best to?
I don't know what is going on, but export HOMEBREW_OPT=/usr/local/opt
in ~/.bash_profile worked for me
Please note we will close your issue without comment if you delete, do not read or do not fill out the issue checklist below and provide ALL the requested information. If you repeatedly fail to use the issue template, we will block you from ever submitting issues to Homebrew again.
brew
command and reproduced the problem with multiple formulae? If it's a problem with a single, official formula (not cask) please file this issue at Homebrew/homebrew-core: https://github.com/Homebrew/homebrew-core/issues/new/choose. If it's abrew cask
problem please file this issue at https://github.com/Homebrew/homebrew-cask/issues/new/choose. If it's a tap (e.g. Homebrew/homebrew-php) problem please file this issue at the tap.brew update
and can still reproduce the problem?brew doctor
, fixed all issues and can still reproduce the problem?brew config
andbrew doctor
and included their output with your issue?To help us debug your issue please explain:
What you were trying to do (and why)
I tried to build a package which uses
pkg-config
from Homebrew.What happened (include command output)
I met an error when build:
It looks like
pkg-config
from Homebrew is not providing the correct include directory of libs shipping with macOS(Xcode and CLI tools). As the release note of Xcode 10, header files which were under/usr/include
no longer exists and been moved to Xcode:/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include
and CLI tools:/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include
.output:
I tested only with
libxml2
but I believe this issue affect all libs which havepkg-config
file from HomebrewLibrary/Homebrew/os/mac/pkgconfig/10.14
, they are: libcurl.pc, libexslt.pc, libxml-2.0.pc, libxslt.pc, sqlite3.pc, zlib.pc.% pkg-config --cflags --libs "libxml-2.0 > 2.6.17"
should gives the correct path to the header files under Xcode or CLI tools.
brew
commands)brew install pkg-config
pkg-config --cflags --libs "libxml-2.0 > 2.6.17"