# CMake Error: The target 'myapp' links to target 'mylib' which uses GLIBCXX_USE_CXX11_ABI=0, but myapp uses GLIBCXX_USE_CXX11_ABI=1. This is an ABI incompatibility.

- **ID:** `cmake/glibcxx-use-cxx11-abi-mismatch`
- **Domain:** cmake
- **Category:** build_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

A project links libraries compiled with different C++ standard library ABI versions (old vs new std::string layout), causing symbol incompatibility at link time.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 3.16 | active | — | — |
| 3.21 | active | — | — |
| 3.24 | active | — | — |
| 3.28 | active | — | — |

## Workarounds

1. **Ensure all dependencies are built with the same ABI setting. Rebuild mylib with -DCMAKE_CXX_FLAGS=-D_GLIBCXX_USE_CXX11_ABI=1 or rebuild myapp with -DCMAKE_CXX_FLAGS=-D_GLIBCXX_USE_CXX11_ABI=0 to match mylib.** (85% success)
   ```
   Ensure all dependencies are built with the same ABI setting. Rebuild mylib with -DCMAKE_CXX_FLAGS=-D_GLIBCXX_USE_CXX11_ABI=1 or rebuild myapp with -DCMAKE_CXX_FLAGS=-D_GLIBCXX_USE_CXX11_ABI=0 to match mylib.
   ```
2. **Use target_compile_definitions(mylib INTERFACE _GLIBCXX_USE_CXX11_ABI=0) or the equivalent for myapp to propagate the ABI choice consistently.** (80% success)
   ```
   Use target_compile_definitions(mylib INTERFACE _GLIBCXX_USE_CXX11_ABI=0) or the equivalent for myapp to propagate the ABI choice consistently.
   ```
3. **If using a package manager like vcpkg or conan, ensure the triplet or profile sets the ABI flag uniformly across all libraries.** (75% success)
   ```
   If using a package manager like vcpkg or conan, ensure the triplet or profile sets the ABI flag uniformly across all libraries.
   ```

## Dead Ends

- **Adding -D_GLIBCXX_USE_CXX11_ABI=0 to CMAKE_CXX_FLAGS for all targets** — This forces the old ABI for all targets, but if system libraries (e.g., Boost) are compiled with the new ABI, the mismatch persists. (70% fail)
- **Manually editing the generated Makefile to remove conflicting flags** — The Makefile is regenerated by CMake on each run, so manual edits are overwritten and not portable across builds. (95% fail)
- **Setting CMAKE_CXX_STANDARD to a lower value to avoid C++11 ABI** — The ABI mismatch is independent of the C++ standard version; it relates to the std::string implementation, not the language standard. (90% fail)
