安装软件包、文档包:
sudo pacman -S qt5-base qt5-doc
安装QTCreator
sudo pacman -S qtcreator
测试代码 helloworld.cpp:
#include <QApplication> #include <QLabel> int main(int argc, char **argv) { QApplication app(argc, argv); QLabel hello("Hello world!"); hello.show(); return app.exec(); }
命令行编译:
g++ $(pkg-config --cflags --libs Qt5Widgets) -fPIC -o helloworld helloworld.cpp
报错:
bash: pkg-config: commond not found
pkg-config 是向用户向程序提供相应库的路径、版本号等信息的程序。
未安装就会报上述错误
解决:
sudo pacman -S pkgconf
安装完成之后重新编译,运行通过。