# # pkg-config: exec: "pkg-config": 在$PATH中找不到可执行文件

- **ID:** `go/missing-cgo-pkg-config`
- **领域:** go
- **类别:** build_error
- **验证级别:** ai_generated
- **修复率:** 88%

## 根因

需要pkg-config进行依赖解析的CGo包在系统PATH中找不到pkg-config工具。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| Go 1.21 | active | — | — |
| Go 1.22 | active | — | — |
| pkg-config 0.29.2 | active | — | — |

## 解决方案

1. ```
   Install pkg-config using the system package manager (e.g., apt-get install pkg-config on Debian/Ubuntu, brew install pkg-config on macOS)
   ```
2. ```
   Set PKG_CONFIG_PATH environment variable to point to custom pkg-config location if installed in non-standard path
   ```

## 无效尝试

- **** — Many CGo packages are essential for system-level operations; disabling CGo breaks compilation. (95% 失败率)
- **** — Some packages cannot be compiled without CGo; this only works for pure Go packages. (60% 失败率)
