compile-error-analysis
Scannednpx machina-cli add skill Jiusi-pys/agent-plugins/compile-error-analysis --openclawFiles (1)
SKILL.md
1.5 KB
Compile Error Analysis Skill
概述
提供 OHOS 交叉编译错误的诊断和修复能力。
错误分类
1. 头文件错误
- 症状:
fatal error: xxx.h: No such file or directory - 参考: references/header-errors.md
2. 符号未定义
- 症状:
undefined reference to 'xxx' - 参考: references/undefined-symbols.md
3. 类型不兼容
- 症状:
error: incompatible types - 参考: references/type-errors.md
4. 链接错误
- 症状:
cannot find -lxxx - 参考: references/linker-errors.md
快速诊断
# 运行错误分析脚本
./scripts/analyze_errors.sh build.log
常见错误速查
| 错误 | 原因 | 修复 |
|---|---|---|
sys/epoll.h not found | Linux 特有 | 使用 poll.h |
undefined reference to 'epoll_create' | Linux 特有 | 条件编译 |
cannot find -lrt | OHOS 在 libc 中 | 移除 -lrt |
incompatible pointer type | ABI 差异 | 检查类型定义 |
OHOS 工具链检查
# 检查 clang
${OHOS_SDK}/native/llvm/bin/clang --version
# 检查 sysroot
ls -la ${OHOS_SDK}/native/sysroot/usr/include/
# 检查库路径
ls -la ${OHOS_SDK}/native/sysroot/usr/lib/aarch64-linux-ohos/
Source
git clone https://github.com/Jiusi-pys/agent-plugins/blob/main/plugins/ohos-porting/skills/compile-error-analysis/SKILL.mdView on GitHub Overview
This skill diagnoses OHOS cross-compilation failures and suggests fixes. It classifies errors into header errors, undefined symbols, type incompatibility, and linker errors, helping pinpoint root causes and guiding remediation. It also supports auto-loading guidance when a compile error occurs.
How This Skill Works
It analyzes the build log, maps symptoms to predefined error classes, and outputs targeted fixes and workarounds. It references common causes and recommended references, and can automatically load relevant guidance when a compile failure happens.
When to Use It
- When a cross-compile fails with a header not found error
- When undefined reference errors appear during linking
- When there is a type incompatibility due to ABI differences
- When encountering linker errors like cannot find -lxxx
- When you need to verify OHOS toolchain setup including clang version, sysroot, and library paths
Quick Start
- Step 1: Run the analysis script with your build log: ./scripts/analyze_errors.sh build.log
- Step 2: Review the recommended fix for the identified error category
- Step 3: Rebuild the project and verify the fix; re-run if needed
Best Practices
- Classify errors into header, symbol, type, and linker categories first
- Run the error analysis script with the build log
- Check OHOS toolchain clues: clang version, sysroot contents, library paths
- Use conditional compilation to isolate OS or ABI differences
- Consult the provided reference files for deeper debugging
Example Use Cases
- fatal error: xxx.h: No such file or directory
- undefined reference to 'xxx'
- error: incompatible types
- cannot find -lrt
- sys/epoll.h not found
Frequently Asked Questions
Add this skill to your agents