我最近一直在从Qt 4.8.5迁移到Qt 5.3.0,这些是相关信息:
现在我遇到了一个问题,我不断遇到编译错误:
致命错误C1083:无法打开包含文件
来自子目录中的头文件,例如#include "FooFolder/bar.h"
。
编译器无法找到所有这类标题,因此我完全糊涂了:
这是我的.pro
文件:
QT += core gui script
QT += printsupport
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = MyApp
TEMPLATE = app
SOURCES += main.cpp\
mainwindow.cpp \
qcustomplot.cpp \
dialogs/filterdialog.cpp \
databox/databox.cpp \
databox/datom.cpp \
#... and more FooFolder/bar.cpp
HEADERS += mainwindow.h \
qcustomplot.h \
dialogs/filterdialog.h \
databox/databox.h \
databox/datom.h \
#... and more FooFolder/bar.h
RESOURCES += \
resources.qrc
win32: LIBS += -LC:/ADLINK/UDASK/lib/ -lusb-dask \
INCLUDEPATH += C:/ADLINK/UDASK/include \
DEPENDPATH += C:/ADLINK/UDASK/include \
include(qext/qextserialport.pri)
这是.h
文件之一,用于包含其他子目录标题
#ifndef SETWINDOW_H
#define SETWINDOW_H
#include <QObject>
#include "databox/databox.h" // <---fatal error C1083: Cannot open include file
class SetWindow: public QObject
{
Q_OBJECT
public:
SetWindow();
public Q_SLOTS:
void setPointNum(int n);
void setStepSize(int s);
int getPointNum();
int getStepSize();
void requestSignal();
Q_SIGNALS:
void sendParameters(int p, int s);
private:
QString DynamicString;
DataBox *presentData;
int m_PointNum;
int m_StepSize;
};
#endif // SETWINDOW_H
并且未能包含头文件:
#ifndef DATABOX_H
#define DATABOX_H
#include <QVector>
#include <QFile>
#include <QMap>
#include <QString>
#include "datom.h"
class Measurement
{
public:
Measurement();
void setNumChan(int n);
void setADRange(QString &s);
void setSamplingRate(int n);
void setTimeBase(double d);
int NumChan;
QString ADRange;
int SamplingRate;
double TimeBase;
};
class DataBox
{
public:
DataBox();
void setCurrentFile(QString path);
void loadData();
void cleanAll();
QVector<double>* py_0;
QVector<double>* py_1;
QVector<double>* ptimeStamp;
QVector<double>* pi_M;
QVector<double>* py_M;
QVector<double>* py_W;
QMap<double, double> AI_0;
QMap<double, double> AI_1;
QMap<int, double> AI0;
QMap<int, double> AI1;
double timeBase;
Measurement parameters;
QVector<Datom> *dataPoints;
private:
QString currentFile;
};
#endif // DATABOX_H
答案 0 :(得分:1)
这些似乎不正确:
win32: LIBS += -LC:/ADLINK/UDASK/lib/ -lusb-dask \
INCLUDEPATH += C:/ADLINK/UDASK/include \
DEPENDPATH += C:/ADLINK/UDASK/include \
1)\
表示它加入下一行,这不是你想要的。对于跟随空行的行不是问题,但这对于INCLUDEPATH
来说不合适,如果用一些包含替换空行,你也可能遇到其他行的问题
2)您还需要将$$PWD
放入包含路径以获取项目根目录&#34;已注册&#34;因为你的include应该从那里开始,而不是源的当前工作目录,因为你可以假设它不是正确的路径。
因此,你会写这样的东西:
win32: LIBS += -LC:/ADLINK/UDASK/lib/ -lusb-dask
INCLUDEPATH += $$PWD C:/ADLINK/UDASK/include
DEPENDPATH += C:/ADLINK/UDASK/include