# error: undefined reference to `some_function'

- **ID:** `go/cgo-ldflags-ordering`
- **Domain:** go
- **Category:** build_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

Library order in `LDFLAGS` matters; if a library depends on another, it must come after.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 1.18 | active | — | — |
| 1.19 | active | — | — |

## Workarounds

1. **Order libraries so that dependencies come after dependents** (90% success)
   ```
   // #cgo LDFLAGS: -lbar -lfoo  // if foo depends on bar
   ```
2. **Use `-Wl,--as-needed` to allow reordering** (80% success)
   ```
   // #cgo LDFLAGS: -Wl,--as-needed -lfoo -lbar
   ```

## Dead Ends

- **Adding `-lfoo` multiple times** — Does not fix dependency order. (60% fail)
- **Using `-Wl,--start-group ... --end-group` incorrectly** — May cause circular dependency issues. (40% fail)
