# 未定义符号：some_function

- **ID:** `go/cgo-undefined-symbol`
- **领域:** go
- **类别:** build_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

在Go中通过`// #include`声明了C函数，但该函数在链接的库中未定义或未链接。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 1.21 | active | — | — |
| 1.22 | active | — | — |

## 解决方案

1. **Explicitly link the correct library with full path** (85% 成功率)
   ```
   // #cgo LDFLAGS: -L/usr/local/lib -lfoo
// #include <foo.h>
import "C"
   ```
2. **Define the missing function in a C source file and compile together** (75% 成功率)
   ```
   Create a .c file next to Go code, then `go build` will compile it.
   ```

## 无效尝试

- **Adding `// #cgo LDFLAGS: -lfoo` without verifying library path** — Library may be in non-standard location or misspelled. (60% 失败率)
- **Reordering C code in the same file** — Does not resolve missing external symbol. (90% 失败率)
