新安装Qtcreator时,运行hello world报编译错误
sudo apt-get install cmake
sudo apt-get install qt5-default qtcreator -y
安装qtcreator以后,默认可以新建一个程序,虽然ctrl+R可以运行,但是debug报错:
Qt Creator 工程出现 main.cpp:10:5: error: unknown type name ‘QApplication’
或
expected a type
或
expected unqualified-id
或
main.cpp:2:1: error: expected ‘}’
ostream:42:1: note: to match this ‘{’
或
main.cpp:7:5: error: use of undeclared identifier ‘cout’
实际已经使用了using namespace std;
需要去:
帮助->关于插件->C++ 去掉Clang Code Model那个勾,然后重启QtCreator