{
  "id": "cmake/install-rpath-missing",
  "signature": "CMake Error: install RPATH file /usr/local/lib/libfoo.so not found in build tree. RPATH settings may be incorrect.",
  "signature_zh": "CMake 错误：安装 RPATH 文件 /usr/local/lib/libfoo.so 在构建树中未找到。RPATH 设置可能不正确。",
  "regex": "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 library path that does not exist in the build tree, often due to a typo or using an absolute path from the host system instead of a build-relative path.",
  "root_cause_type": "generic",
  "root_cause_zh": "目标的 INSTALL_RPATH 属性引用了构建树中不存在的库路径，通常是因为拼写错误或使用了主机系统的绝对路径而非构建相对路径。",
  "versions": [
    {
      "version": "CMake 3.0+",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Linux x86_64",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Set CMAKE_SKIP_RPATH to ON to skip RPATH processing entirely",
      "why_fails": "Skips the check but may cause runtime failures because the installed binary cannot find its shared libraries.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "Manually create the missing file as a symlink",
      "why_fails": "The build tree is ephemeral; symlinks break after clean build. Also, the error is about the path not existing, not the file.",
      "fail_rate": 0.85,
      "condition": "",
      "sources": []
    },
    {
      "action": "Change INSTALL_RPATH to use $ORIGIN (relative path)",
      "why_fails": "While this is a good practice, simply changing to $ORIGIN without correcting the actual path still fails if the path is malformed.",
      "fail_rate": 0.5,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Correct the INSTALL_RPATH property to use build-relative paths. For example, if the library is in ${CMAKE_BINARY_DIR}/lib, set: set_target_properties(mytarget PROPERTIES INSTALL_RPATH \"${CMAKE_INSTALL_PREFIX}/lib\").",
      "success_rate": 0.9,
      "how": "Correct the INSTALL_RPATH property to use build-relative paths. For example, if the library is in ${CMAKE_BINARY_DIR}/lib, set: set_target_properties(mytarget PROPERTIES INSTALL_RPATH \"${CMAKE_INSTALL_PREFIX}/lib\").",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use generator expressions to set RPATH conditionally: set_target_properties(mytarget PROPERTIES INSTALL_RPATH \"$ORIGIN/../lib\"). This uses the installed binary's location.",
      "success_rate": 0.95,
      "how": "Use generator expressions to set RPATH conditionally: set_target_properties(mytarget PROPERTIES INSTALL_RPATH \"$ORIGIN/../lib\"). This uses the installed binary's location.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Remove the incorrect INSTALL_RPATH and rely on CMake's default RPATH handling: just remove the set_target_properties line and reconfigure.",
      "success_rate": 0.8,
      "how": "Remove the incorrect INSTALL_RPATH and rely on CMake's default RPATH handling: just remove the set_target_properties line and reconfigure.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "更正 INSTALL_RPATH 属性以使用构建相对路径。例如，如果库在 ${CMAKE_BINARY_DIR}/lib 中，设置：set_target_properties(mytarget PROPERTIES INSTALL_RPATH \"${CMAKE_INSTALL_PREFIX}/lib\")。",
    "使用生成器表达式条件设置 RPATH：set_target_properties(mytarget PROPERTIES INSTALL_RPATH \"$ORIGIN/../lib\")。这使用了已安装二进制文件的位置。",
    "移除错误的 INSTALL_RPATH 并依赖 CMake 的默认 RPATH 处理：直接删除 set_target_properties 行并重新配置。"
  ],
  "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.87,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2023-09-05",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}