go
build_error
ai_generated
true
# pkg-config: exec: "pkg-config": executable file not found in $PATH
ID: go/missing-cgo-pkg-config
88%Fix Rate
82%Confidence
1Evidence
2024-02-20First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| Go 1.21 | active | — | — | — |
| Go 1.22 | active | — | — | — |
| pkg-config 0.29.2 | active | — | — | — |
Root Cause
CGo packages requiring pkg-config for dependency resolution cannot find the pkg-config tool in the system PATH.
generic中文
需要pkg-config进行依赖解析的CGo包在系统PATH中找不到pkg-config工具。
Official Documentation
https://pkg.go.dev/cmd/cgoWorkarounds
-
95% success Install pkg-config using the system package manager (e.g., apt-get install pkg-config on Debian/Ubuntu, brew install pkg-config on macOS)
Install pkg-config using the system package manager (e.g., apt-get install pkg-config on Debian/Ubuntu, brew install pkg-config on macOS)
-
85% success Set PKG_CONFIG_PATH environment variable to point to custom pkg-config location if installed in non-standard path
Set PKG_CONFIG_PATH environment variable to point to custom pkg-config location if installed in non-standard path
中文步骤
Install pkg-config using the system package manager (e.g., apt-get install pkg-config on Debian/Ubuntu, brew install pkg-config on macOS)
Set PKG_CONFIG_PATH environment variable to point to custom pkg-config location if installed in non-standard path
Dead Ends
Common approaches that don't work:
-
95% fail
Many CGo packages are essential for system-level operations; disabling CGo breaks compilation.
-
60% fail
Some packages cannot be compiled without CGo; this only works for pure Go packages.