{
  "id": "cmake/glibcxx-use-cxx11-abi-mismatch",
  "signature": "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.",
  "signature_zh": "CMake 错误：目标 'myapp' 链接到目标 'mylib'，后者使用 GLIBCXX_USE_CXX11_ABI=0，但 myapp 使用 GLIBCXX_USE_CXX11_ABI=1。这是 ABI 不兼容问题。",
  "regex": "CMake Error: The target '.*' links to target '.*' which uses GLIBCXX_USE_CXX11_ABI=[01], but .* uses GLIBCXX_USE_CXX11_ABI=[01]\\. This is an ABI incompatibility\\.",
  "domain": "cmake",
  "category": "build_error",
  "subcategory": null,
  "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.",
  "root_cause_type": "generic",
  "root_cause_zh": "项目链接了使用不同 C++ 标准库 ABI 版本（旧版与新版 std::string 布局）编译的库，导致链接时符号不兼容。",
  "versions": [
    {
      "version": "3.16",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "3.21",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "3.24",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "3.28",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Adding -D_GLIBCXX_USE_CXX11_ABI=0 to CMAKE_CXX_FLAGS for all targets",
      "why_fails": "This forces the old ABI for all targets, but if system libraries (e.g., Boost) are compiled with the new ABI, the mismatch persists.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "Manually editing the generated Makefile to remove conflicting flags",
      "why_fails": "The Makefile is regenerated by CMake on each run, so manual edits are overwritten and not portable across builds.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    },
    {
      "action": "Setting CMAKE_CXX_STANDARD to a lower value to avoid C++11 ABI",
      "why_fails": "The ABI mismatch is independent of the C++ standard version; it relates to the std::string implementation, not the language standard.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "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.",
      "success_rate": 0.85,
      "how": "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.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use target_compile_definitions(mylib INTERFACE _GLIBCXX_USE_CXX11_ABI=0) or the equivalent for myapp to propagate the ABI choice consistently.",
      "success_rate": 0.8,
      "how": "Use target_compile_definitions(mylib INTERFACE _GLIBCXX_USE_CXX11_ABI=0) or the equivalent for myapp to propagate the ABI choice consistently.",
      "condition": "",
      "sources": []
    },
    {
      "action": "If using a package manager like vcpkg or conan, ensure the triplet or profile sets the ABI flag uniformly across all libraries.",
      "success_rate": 0.75,
      "how": "If using a package manager like vcpkg or conan, ensure the triplet or profile sets the ABI flag uniformly across all libraries.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "确保所有依赖项使用相同的 ABI 设置。使用 -DCMAKE_CXX_FLAGS=-D_GLIBCXX_USE_CXX11_ABI=1 重新编译 mylib，或使用 -DCMAKE_CXX_FLAGS=-D_GLIBCXX_USE_CXX11_ABI=0 重新编译 myapp 以匹配 mylib。",
    "在 CMakeLists.txt 中使用 target_compile_definitions(mylib INTERFACE _GLIBCXX_USE_CXX11_ABI=0) 或为 myapp 使用相应设置，以一致地传播 ABI 选择。",
    "如果使用 vcpkg 或 conan 等包管理器，请确保 triplet 或 profile 在所有库中统一设置 ABI 标志。"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_dual_abi.html",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.85,
  "fix_success_rate": 0.8,
  "resolvable": "partial",
  "first_seen": "2023-05-10",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}