大家好,我有一个qmake使用的问题
我在通过一本教材学习qt,教材附带源程序
我在windows下通过visual studio编译源程序做练习
通常,我拿来源程序,通过运行以下两句生成vc的project文件
- qmake -project -t vcapp
- qmake
然后再在vc环境里继续工作,一直工作的挺好
但是下面这个小例子编译后,运行结果不是期待的样子
- #include <QtCore>
- #include <iostream>
- #include <stdio.h>
- using namespace std;
- int main(int argc, char* argv[])
- {
- if (argc < 2) {
- cout << "Usage: " << argv[0] << " infile [outfile]" << endl;
- return 1;
- }
- QFile in(argv[1]);
- if(!in.open(QIODevice::ReadOnly|QIODevice::Text)) {
- cerr << "File " << argv[1] << " does not exist" << endl;
- }
- QFile out;
- if (argc >= 3) {
- out.setFileName(argv[2]);
- if (out.exists()) {
- cerr << "File" << argv[2] << " already exists" << endl;
- return 1;
- }
- if(!out.open(QIODevice::WriteOnly|QIODevice::Text)) {
- cerr << "Failed to open file " << argv[2] <<
- " for writing" << endl;
- return 1;
- }
- }
- else
- if(!out.open(stdout, QIODevice::WriteOnly|QIODevice::Text)) {
- cerr << "Failed to open standard output for writing" << endl;
- return 1;
- }
- while (!in.atEnd()) {
- QByteArray line = in.readLine();
- if (!line.trimmed().isEmpty() &&
- !line.trimmed().startsWith('#'))
- out.write(line);
- }
- in.close();
- out.close();
- return 0;
- }
程序可以运行,但是不对任何参数的组合做任何响应。
程序本身没有问题了,因为我用手动添加qt支持的方法 添加$(QTDIR)/include qtmaind.lib QtGuid4.lib QtCored4.lib $(QTDIR)/lib
再编译程序,结果就和想要的一样了
我的问题是,qmake应该强大到可以处理这个问题
那么qmake针对这个问题该怎么用呢? 谢谢