目录
一、环境
硬件:Jetson Xavier NX 套件
系统:Ubuntu 20.04
QT :QT5.12.9
QT Creator:4.11
二、问题
报错找不到“stddef.h”头文件,但是切换过去查看,头文件是存在并且能正常打开的。而且虽然报错,但是能够成功运行。
找得到头文件,但是提示unknown type name 'QGuiApplication'、use of undeclared identifier 'QFontDatabase'等错误
cstddef:50:10: fatal error: 'stddef.h' file not found
main.cpp:1:1: note: in file included from /home/main.cpp:1:
main.cpp:1:10: note: in file included from /home/main.cpp:1:
QGuiApplication:1:10: note: in file included from /opt/qt5.12.9_aarch64/include/QtGui/QGuiApplication:1:
qguiapplication.h:43:10: note: in file included from /opt/qt5.12.9_aarch64/include/QtGui/qguiapplication.h:43:
qtguiglobal.h:43:10: note: in file included from /opt/qt5.12.9_aarch64/include/QtGui/qtguiglobal.h:43:
qglobal.h:46:12: note: in file included from /opt/qt5.12.9_aarch64/include/QtCore/qglobal.h:46:
main.cpp:34:5: error: no matching function for call to 'qputenv'
qglobal.h:1259:20: note: candidate function not viable: no known conversion from 'const char [7]' to 'const QByteArray' for 2nd argument
main.cpp:35:29: error: 'QByteArray' is an incomplete type
qglobal.h:1254:7: note: forward declaration of 'QByteArray'
main.cpp:40:5: error: unknown type name 'QGuiApplication'
main.cpp:43:5: error: calling 'debug' with incomplete return type 'QDebug'
qlogging.h:164:91: note: expanded from macro 'qDebug'
qlogging.h:126:12: note: 'debug' declared here
qlogging.h:57:7: note: forward declaration of 'QDebug'
main.cpp:50:5: error: use of undeclared identifier 'QFontDatabase'
三、解决方法
方法一:取消使用 ClangCodeModel 插件,此插件会对代码进行分析,然后给出警告。关闭后会丧失智能提醒的功能。
方法二:安装合适版本的libclang-common组件【建议】
1、查看系统安装的组件版本
apt list --installed | grep "libclang-common*"
2、安装低版本组件 ,由于ClangCodeModel 4.11需要libclang-common-8-dev,所以安装libclang-common-8-dev
sudo apt-get install libclang-common-8-dev
3、重启QT Creator
OK!
至此,问题解决。