linux和windows中命令列編譯qt程式步驟
注:此方法未經本人證實
1、開啟環境變數設定視窗,編輯 PATH 變數,新增如下內容:
c:/Qt/2010.02.1/bin/;
c:/Qt/2010.02.1/qt/bin/;
c:/Qt/2010.02.1/mingw/bin/
2、開啟環境變數設定視窗,新增環境變數QTDIR:
變數名:QTDIR
變數值:C:/Qt/2010.02.1/qt
3、開啟環境變數設定視窗,新增環境變數QMAKESPEC:
變數名:QMAKESPEC
變數值:win32-g++
4、現在已經可以進行命令列模式的編譯了,例如:
a、建立一個空資料夾 hello,然後在其中建立一個空檔案 hello.cpp,編輯並儲存此檔案。
#include QApplication>
#include QPushButton>
int main(int argc,char* argv[])
{
QApplication app(argc,argv);
QPushButton * bt = new QPushButton("quit");
QObject::connect(bt,SIGNAL(clicked()),&app,SLOT(exit()));
bt->show();
return app.exec();
}
b、在hello目錄下,命令列輸入執行 qmake -project,生成 hello.pro
c、在hello目錄下,命令列輸入執行 qmake hello.pro,生成了 makefile
d、在hello目錄下,命令列輸入執行 mingw32-make,生成了 hello.exe(位於 Debug 目錄下)
e、進入 Debug 目錄,執行 hello.exe
轉載自:https://www.cnblogs.com/xiahaimq/p/6269429.html