如何使用 qmake-qt4 构建项目?

如何使用 qmake-qt4 构建项目?

我是 Ubuntu 的新用户,如果我的问题太明显,请原谅我。

我在VirtualBox中安装了32位的Ubuntu 11.10,我想用 构建一个项目qmake-qt4,问题是我对此一无所知,我在谷歌上搜索过,但我找到的是如何使用一个项目文件生成另一个项目文件和一个Makefile,但是我下载的项目包中有所有这些(Makefile,.pro文件),直接输入make命令得到的结果如下:

make: Nothing to be done for `first'

如果我使用qmake-qt4 -project, qmake-qt4, make

/usr/bin/qmake-qt4 -o Makefile GATE_PET_2_STIR.pro
g++ -c -pipe -O2 -Wall -W -D_REENTRANT -DQT_WEBKIT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. -Iinclude/qwt-6.0.2 -Iinclude/root -IViewer -I. -I. -o viewer.o Viewer/viewer.cpp
In file included from Viewer/viewer.cpp:1:0:
Viewer/viewer.h:101:42: error: ‘Daq_Project’ has not been declared
Viewer/viewer.h:103:17: error: ‘Daq_Project’ has not been declared
Viewer/viewer.cpp:22:33: error: ‘Daq_Project’ has not been declared
Viewer/viewer.cpp:22:1: warning: unused parameter ‘_daq_project’ [-Wunused-parameter]
Viewer/viewer.cpp: In member function ‘void Viewer::on_listWidget_clicked(const QModelIndex&)’:
Viewer/viewer.cpp:74:9: error: ‘pr_data’ was not declared in this scope
Viewer/viewer.cpp:74:19: error: ‘daq_project’ was not declared in this scope
Viewer/viewer.cpp: In member function ‘void Viewer::on_listWidget_2_clicked(const QModelIndex&)’:
Viewer/viewer.cpp:120:5: error: ‘Data_module’ was not declared in this scope
Viewer/viewer.cpp:120:18: error: ‘pr_data’ was not declared in this scope
Viewer/viewer.cpp:124:19: error: ‘daq_project’ was not declared in this scope
Viewer/viewer.cpp: At global scope:
Viewer/viewer.cpp:160:6: warning: unused parameter ‘index’ [-Wunused-parameter]
Viewer/viewer.cpp: In member function ‘void Viewer::on_listWidget_3_clicked(const QModelIndex&)’:
Viewer/viewer.cpp:169:5: error: ‘Data_module’ was not declared in this scope
Viewer/viewer.cpp:169:18: error: ‘pr_data’ was not declared in this scope
Viewer/viewer.cpp:173:19: error: ‘daq_project’ was not declared in this scope
Viewer/viewer.cpp: In member function ‘virtual void Viewer::closeEvent(QCloseEvent*)’:
Viewer/viewer.cpp:217:23: error: ‘daq_project’ was not declared in this scope
Viewer/viewer.cpp: At global scope:
Viewer/viewer.cpp:215:6: warning: unused parameter ‘event’ [-Wunused-parameter]
make: *** [viewer.o] Error 1

我应该怎么做才能修复这些错误?

答案1

首先,将代码恢复到之前的样子。运行时,qmake-qt4 -project你破坏了之前的代码(可能是正确的).pro

回到开始后,导航到包含 .pro 的目录并输入qmake-qt4。这将Makefile根据 .pro 中的特征生成一个。完成后,运行make。这应该会构建整个项目(假设您已经拥有qt4 构建依赖项已安装)。如果没有,下载 Qt 4 源代码并关注这些说明

相关内容