Tur*_*000 5 gcc qt c++ g++ qt-creator
我已经从 Ubuntu 18.04 升级到 20.04,除了一些令人讨厌的grub问题之外,大多数东西都是开箱即用的。但是我的 QtCreator ( Qt Creator 4.11.0, Based on Qt 5.12.8 (GCC 9.3.0, 64 bit)) 在识别包含的库时遇到了问题。它在更新前运行良好的项目中显示了数千条错误消息。错误消息看起来都像链接器错误消息。一些例子:
error: 'std::string' (aka 'int') is not a class, namespace, or enumeration
error: no matching function for call to 'getline'
error: member reference base type 'std::ifstream' (aka 'int') is not a structure or union
error: no template named 'vector' in namespace 'std'
error: unknown type name 'SystemCallFactory' //this class is from the same project
Run Code Online (Sandbox Code Playgroud)
甚至 qt 和 std 库中的一些错误:
/usr/include/x86_64-linux-gnu/qt5/QtCore/qstring.h:1374: passing argument to parameter 's' here
/usr/include/c++/8/ostream:41: candidate found by name lookup is 'std'
Run Code Online (Sandbox Code Playgroud)
当我在 QtCreator 中创建一个新项目而不更改默认代码的任何内容时,它是相同的:
/home/$me/src/untitled/main.cpp:7: error: variable has incomplete type 'QApplication'`
/home/$me/src/untitled/main.cpp:8: error: unknown type name 'MainWindow'
Run Code Online (Sandbox Code Playgroud)
安装的编译器:
update-alternatives --display gcc
gcc - 自动模式链接最佳版本是 /usr/bin/gcc-8 链接当前指向 /usr/bin/gcc-8 链接 gcc 是 /usr/bin/gcc /usr/bin/gcc -8 - 优先级 30 /usr/bin/gcc-9 - 优先级 20update-alternatives --display g++ g++ - 自动模式链接最佳版本是 /usr/bin/g++-8 链接当前指向 /usr/bin/g++-8 链接 g++ 是 /usr/bin/g++ /usr/bin/g++ -8 - 优先级 30 /usr/bin/g++-9 - 优先级 20
我仍然可以手动构建所有项目,同样 cmake 和 qmake 都可以在这里工作。此外,当我在 QtCreator 中设置的构建目录中进行完整构建时,QtCreator 将构建我的项目,即使我更改了某些内容。它仍然会在我的代码和issues部分中显示错误,但无论如何都会构建和运行,所以构建命令应该没问题。但是当构建目录为空时,它会失败。
我怎样才能进一步解决这个问题?
小智 6
同样的问题,与@nou 相同的解决方案。QtCreator 4.11 仍然依赖于 clang-8,但在 Ubuntu 20.04 apt 将安装 clang-10。以下为我解决了这个问题:
安装叮当 8
sudo apt install clang-8
Run Code Online (Sandbox Code Playgroud)
更新备选方案
sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-8 100
sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-8 100
Run Code Online (Sandbox Code Playgroud)
我不需要重新安装 QtCreator。
| 归档时间: |
|
| 查看次数: |
3441 次 |
| 最近记录: |