# error: cgo: dynamic library not found: libfoo.so: cannot open shared object file: No such file or directory

- **ID:** `go/cgo-dynamic-library-not-found`
- **Domain:** go
- **Category:** build_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

Dynamic library (`.so`) not in standard library paths or `LD_LIBRARY_PATH`.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 1.20 | active | — | — |
| 1.21 | active | — | — |

## Workarounds

1. **Set `LD_LIBRARY_PATH` before running** (90% success)
   ```
   export LD_LIBRARY_PATH=/path/to/lib:$LD_LIBRARY_PATH
./program
   ```
2. **Use `-rpath` in LDFLAGS with absolute path** (85% success)
   ```
   // #cgo LDFLAGS: -rpath,/path/to/lib -L/path/to/lib -lfoo
   ```

## Dead Ends

- **Copying .so to current directory** — Current directory not searched by default. (70% fail)
- **Using `-rpath` without absolute path** — Relative rpath may break if binary moved. (50% fail)
