{
  "id": "cmake/install-rpath-not-found",
  "signature": "CMake Error: install RPATH file /usr/local/lib/libfoo.so not found in build tree.",
  "signature_zh": "CMake 错误：安装 RPATH 文件 /usr/local/lib/libfoo.so 在构建树中未找到。",
  "regex": "CMake Error: install RPATH file .* not found in build tree",
  "domain": "cmake",
  "category": "install_error",
  "subcategory": null,
  "root_cause": "The INSTALL_RPATH property of a target references a file path that does not exist in the build directory, often due to a missing dependency build or incorrect path variable expansion.",
  "root_cause_type": "generic",
  "root_cause_zh": "目标的 INSTALL_RPATH 属性引用了构建目录中不存在的文件路径，通常是由于缺少依赖构建或路径变量展开不正确。",
  "versions": [
    {
      "version": "CMake 3.10",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "CMake 3.14",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "CMake 3.20",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Setting CMAKE_PREFIX_PATH to include the missing library directory",
      "why_fails": "Adding the missing library path to CMAKE_PREFIX_PATH does not affect INSTALL_RPATH, which is a target property, not a find_package search path.",
      "fail_rate": 0.75,
      "condition": "",
      "sources": []
    },
    {
      "action": "Creating a symbolic link in the build tree to the missing library",
      "why_fails": "Manually creating a symlink in the build directory may bypass the error but will break on clean builds or different systems.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "Setting CMAKE_SKIP_RPATH to ON to skip RPATH installation",
      "why_fails": "Disabling RPATH entirely with CMAKE_SKIP_RPATH removes the error but causes runtime linking failures on systems without the library in standard paths.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Correct the INSTALL_RPATH target property to use a valid build-tree path, e.g., `set_target_properties(mylib PROPERTIES INSTALL_RPATH \"${CMAKE_BINARY_DIR}/lib\")`.",
      "success_rate": 0.9,
      "how": "Correct the INSTALL_RPATH target property to use a valid build-tree path, e.g., `set_target_properties(mylib PROPERTIES INSTALL_RPATH \"${CMAKE_BINARY_DIR}/lib\")`.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Ensure the referenced library is built before the target by adding a dependency: `add_dependencies(mylib libfoo)`.",
      "success_rate": 0.85,
      "how": "Ensure the referenced library is built before the target by adding a dependency: `add_dependencies(mylib libfoo)`.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use generator expressions in INSTALL_RPATH to conditionally include paths only when they exist, e.g., `$<TARGET_FILE_DIR:libfoo>`.",
      "success_rate": 0.8,
      "how": "Use generator expressions in INSTALL_RPATH to conditionally include paths only when they exist, e.g., `$<TARGET_FILE_DIR:libfoo>`.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "更正 INSTALL_RPATH 目标属性以使用有效的构建树路径，例如 `set_target_properties(mylib PROPERTIES INSTALL_RPATH \"${CMAKE_BINARY_DIR}/lib\")`。",
    "通过添加依赖确保引用的库在目标之前构建：`add_dependencies(mylib libfoo)`。",
    "在 INSTALL_RPATH 中使用生成器表达式有条件地包含路径（仅当存在时），例如 `$<TARGET_FILE_DIR:libfoo>`。"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://cmake.org/cmake/help/latest/prop_tgt/INSTALL_RPATH.html",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.83,
  "fix_success_rate": 0.85,
  "resolvable": "true",
  "first_seen": "2023-11-20",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}