我正在使用最初使用MinGW64(gcc 4.8)编译的Qt / C ++开发项目。我决定将它“移植”到MSVC2013,因为我需要使用一些在MinGW中不能很好地运行的Windows API函数,但是现在我遇到了这个错误:
mainwindow.obj:-1: error: LNK2019: unresolved external symbol "public: void __cdecl IMLoginView::clearFieldPass(void)" (?clearFieldPass@IMLoginView@@QEAAXXZ) referenced in function "public: void __cdecl MainWindow::showConnectionErrorDialog(void)" (?showConnectionErrorDialog@MainWindow@@QEAAXXZ)
imingestinglist.obj:-1: error: LNK2019: unresolved external symbol "public: static class QString __cdecl IMStorageSystem::getLogDir(void)" (?getLogDir@IMStorageSystem@@SA?AVQString@@XZ) referenced in function "private: class QList<int> __cdecl IMIngestingList::loadList(void)" (?loadList@IMIngestingList@@AEAA?AV?$QList@H@@XZ)
moc_imloginview.obj:-1: error: LNK2019: unresolved external symbol "public: void __cdecl IMLoginView::login(void)" (?login@IMLoginView@@QEAAXXZ) referenced in function "private: static void __cdecl IMLoginView::qt_static_metacall(class QObject *,enum QMetaObject::Call,int,void * *)" (?qt_static_metacall@IMLoginView@@CAXPEAVQObject@@W4Call@QMetaObject@@HPEAPEAX@Z)
moc_imloginview.obj:-1: error: LNK2019: unresolved external symbol "public: void __cdecl IMLoginView::handleError(enum ALFRED_ACCESS_ERROR)" (?handleError@IMLoginView@@QEAAXW4ALFRED_ACCESS_ERROR@@@Z) referenced in function "private: static void __cdecl IMLoginView::qt_static_metacall(class QObject *,enum QMetaObject::Call,int,void * *)" (?qt_static_metacall@IMLoginView@@CAXPEAVQObject@@W4Call@QMetaObject@@HPEAPEAX@Z)
moc_imloginview.obj:-1: error: LNK2019: unresolved external symbol "public: void __cdecl IMLoginView::userDisconnected(void)" (?userDisconnected@IMLoginView@@QEAAXXZ) referenced in function "private: static void __cdecl IMLoginView::qt_static_metacall(class QObject *,enum QMetaObject::Call,int,void * *)"
问题是:这些方法不是某些外部库的一部分,而是项目本身的一部分。我已经三次检查它们是否已实施。它们既不是任何模板类的一部分,也不是普通类,日志表示正在编译cpp文件。同一个项目与MinGW64很好地联系。
我目前正在使用Qt Creator 3.3.2和QT 5.3.2。
可能会发生什么?
编辑:
我无法显示太多代码,因为它是一个闭源项目,但我至少可以显示方法的标题和实现布局:
imloginview.h:
class IMLoginView : public QWidget
{
Q_OBJECT
public:
explicit IMLoginView(QWidget *parent = 0);
void clearFieldPass();
~IMLoginView();
private:
//Lots of attributes
void configureComponents();
void keyPressEvent(QKeyEvent *event);
signals:
public slots:
void login();
void handleError(ALFRED_ACCESS_ERROR error);
void userDisconnected();
}
imloginview.cpp:
IMLoginView::IMLoginView(QWidget *parent) : //lots of initializations here
{
//Implementation
}
IMLoginView::~IMLoginView()
{
}
void IMLoginView::clearFieldPass()
{
//implementation
}
void IMLoginView::configureComponents()
{
//Implementation
}
void IMLoginView::keyPressEvent(QKeyEvent *event)
{
//implementation
}
void IMLoginView::login()
{
//implementation
}
void IMLoginView::handleError(ALFRED_ACCESS_ERROR error)
{
//implementation
}
void IMLoginView::userDisconnected()
{
//implementation
}
对不起,我真的无法提供实际的方法代码,但它的封闭源代码。 = /