Ubuntu Qt: ninja: build stopped:subcommand failed解决方案

编译Qt源码时,出现报错:

ninja: build stopped:subcommand failed

滑动终端上的编译日志,通过日志上的**FAILED:**信息可以查看是编译哪个库导致的失败.

我的报错信息是:

FAILED: not found qtbase/bin/lupdate

结果反复测试,最终发现qtbase/bin目录下的lupdate文件在编译时总是自动消失,继续查看日志,最后发现:

undefined reference to `typeinfo for clang::ASTFrontendAction
undefined reference to `typeinfo for clang::ASTConsumer
undefined reference to `typeinfo for clang::DiagnosticConsumer
undefined reference to `typeinfo for clang::PPCallbacks

报错原因:
因为Qt需要LLVM来生成qdoc. 在Ubuntu中通过安装包或者源码安装的LLVM,LLVM/Clang默认是禁用RTTI.

解决方案 1:
不需要生成qdoc, 那么在配置configure时增加-no-feature-clang, 没有实际验证过, 需要自行测试.

./configure -no-feature-clang

解决方案 2:
通过源码重装LLVM, 参考M1 arm环境 - Ubuntu 22.04 源码安装LLVM, 重装完成LLVM后,继续执行命令,继续编译Qt:

cmake --build . --parallel 2

亲测会继续编译Qt 剩余未编译部分, 不要重新执行 ./configure

比较稳妥流程:

rm -rf CmakeCache.txt
./configure
cmake --build . --parallel 2
sudo cmake --install .

参考:
M1 arm环境 - Ubuntu 22.04 源码安装LLVM

GitHub 加速计划 / ni / ninja
6
0
下载
a small build system with a focus on speed
最近提交(Master分支:4 个月前 )
2d77de5e Make sure to carry the old uid and gid on file replace 3 天前
0311d436 Support $^ escape sequence for newlines. 3 天前
Logo

AtomGit 是由开放原子开源基金会联合 CSDN 等生态伙伴共同推出的新一代开源与人工智能协作平台。平台坚持“开放、中立、公益”的理念,把代码托管、模型共享、数据集托管、智能体开发体验和算力服务整合在一起,为开发者提供从开发、训练到部署的一站式体验。

更多推荐