2017-01-16 4 views
0

Почему я не могу создать и запустить проект? Я добавил необходимые .lib-файлы в свойства ввода компоновщика, добавил каталог Qt «include» в дополнительные папки ввода, скопировал файлы DLL в папку проекта и т. Д. Visual Studio все еще жалуется на нерешенные внешние символы. Что мне делать?Преобразовал проект Qt в проект VC++ - нерешенные внешние символы

файл main.cpp, как так:

#include <QtWidgets/QApplication> 
#include <QtWidgets/QLabel> 

int main(int argc, char* argv[]) { 

    QApplication app(argc, argv); 
    QLabel* label = new QLabel("Hello Qt!"); 
    label->show(); 
    return app.exec(); 
} 

Файл .pro выглядит следующим образом:

###################################################################### 
# Automatically generated by qmake (3.1) Tue Jan 17 00:13:06 2017 
###################################################################### 

QT += core gui widgets 

TEMPLATE = app 
TARGET = hello 
INCLUDEPATH += . 

# Input 
SOURCES += main.cpp 

Список ошибок ниже:

1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __cdecl QApplication::QApplication(int &,char * *,int)" ([email protected]@[email protected]@Z) referenced in function main 
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __cdecl QApplication::~QApplication(void)" ([email protected]@[email protected]) referenced in function main 
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: static int __cdecl QApplication::exec(void)" ([email protected]@@SAHXZ) referenced in function main 
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __cdecl QWidget::show(void)" ([email protected]@@QEAAXXZ) referenced in function main 
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __cdecl QLabel::QLabel(class QString const &,class QWidget *,class QFlags<enum Qt::WindowType>)" ([email protected]@[email protected]@@[email protected]@[email protected]@[email protected]@@@@Z) referenced in function main 
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __cdecl QLabel::~QLabel(void)" ([email protected]@[email protected]) referenced in function "public: virtual void * __cdecl QLabel::`scalar deleting destructor'(unsigned int)" ([email protected]@[email protected]) 
1>main.obj : error LNK2001: unresolved external symbol "protected: virtual void __cdecl QWidget::actionEvent(class QActionEvent *)" ([email protected]@@[email protected]@@Z) 
1>main.obj : error LNK2001: unresolved external symbol "protected: virtual void __cdecl QLabel::changeEvent(class QEvent *)" ([email protected]@@[email protected]@@Z) 
1>main.obj : error LNK2001: unresolved external symbol "protected: virtual void __cdecl QWidget::closeEvent(class QCloseEvent *)" ([email protected]@@[email protected]@@Z) 
1>main.obj : error LNK2001: unresolved external symbol "protected: virtual void __cdecl QLabel::contextMenuEvent(class QContextMenuEvent *)" ([email protected]@@[email protected]@@Z) 
1>main.obj : error LNK2001: unresolved external symbol "public: virtual int __cdecl QWidget::devType(void)const " ([email protected]@@UEBAHXZ) 
1>main.obj : error LNK2001: unresolved external symbol "protected: virtual void __cdecl QWidget::dragEnterEvent(class QDragEnterEvent *)" ([email protected]@@[email protected]@@Z) 
1>main.obj : error LNK2001: unresolved external symbol "protected: virtual void __cdecl QWidget::dragLeaveEvent(class QDragLeaveEvent *)" ([email protected]@@[email protected]@@Z) 
1>main.obj : error LNK2001: unresolved external symbol "protected: virtual void __cdecl QWidget::dragMoveEvent(class QDragMoveEvent *)" ([email protected]@@[email protected]@@Z) 
1>main.obj : error LNK2001: unresolved external symbol "protected: virtual void __cdecl QWidget::dropEvent(class QDropEvent *)" ([email protected]@@[email protected]@@Z) 
1>main.obj : error LNK2001: unresolved external symbol "protected: virtual void __cdecl QWidget::enterEvent(class QEvent *)" ([email protected]@@[email protected]@@Z) 
1>main.obj : error LNK2001: unresolved external symbol "protected: virtual bool __cdecl QLabel::event(class QEvent *)" ([email protected]@@[email protected]@@Z) 
1>main.obj : error LNK2001: unresolved external symbol "protected: virtual void __cdecl QLabel::focusInEvent(class QFocusEvent *)" ([email protected]@@[email protected]@@Z) 
1>main.obj : error LNK2001: unresolved external symbol "protected: virtual bool __cdecl QLabel::focusNextPrevChild(bool)" ([email protected]@@[email protected]) 
1>main.obj : error LNK2001: unresolved external symbol "protected: virtual void __cdecl QLabel::focusOutEvent(class QFocusEvent *)" ([email protected]@@[email protected]@@Z) 
1>main.obj : error LNK2001: unresolved external symbol "public: virtual bool __cdecl QWidget::hasHeightForWidth(void)const " ([email protected]@@UEBA_NXZ) 
1>main.obj : error LNK2001: unresolved external symbol "public: virtual int __cdecl QLabel::heightForWidth(int)const " ([email protected]@@[email protected]) 
1>main.obj : error LNK2001: unresolved external symbol "protected: virtual void __cdecl QWidget::hideEvent(class QHideEvent *)" ([email protected]@@[email protected]@@Z) 
1>main.obj : error LNK2001: unresolved external symbol "protected: virtual void __cdecl QWidget::initPainter(class QPainter *)const " ([email protected]@@[email protected]@@Z) 
1>main.obj : error LNK2001: unresolved external symbol "protected: virtual void __cdecl QWidget::inputMethodEvent(class QInputMethodEvent *)" ([email protected]@@[email protected]@@Z) 
1>main.obj : error LNK2001: unresolved external symbol "public: virtual class QVariant __cdecl QWidget::inputMethodQuery(enum Qt::InputMethodQuery)const " ([email protected]@@[email protected]@[email protected]@@@Z) 
1>main.obj : error LNK2001: unresolved external symbol "protected: virtual void __cdecl QLabel::keyPressEvent(class QKeyEvent *)" ([email protected]@@[email protected]@@Z) 
1>main.obj : error LNK2001: unresolved external symbol "protected: virtual void __cdecl QWidget::keyReleaseEvent(class QKeyEvent *)" ([email protected]@@[email protected]@@Z) 
1>main.obj : error LNK2001: unresolved external symbol "protected: virtual void __cdecl QWidget::leaveEvent(class QEvent *)" ([email protected]@@[email protected]@@Z) 
1>main.obj : error LNK2001: unresolved external symbol "public: virtual struct QMetaObject const * __cdecl QLabel::metaObject(void)const " ([email protected]@@[email protected]@XZ) 
1>main.obj : error LNK2001: unresolved external symbol "protected: virtual int __cdecl QWidget::metric(enum QPaintDevice::PaintDeviceMetric)const " ([email protected]@@[email protected]@@@Z) 
1>main.obj : error LNK2001: unresolved external symbol "public: virtual class QSize __cdecl QLabel::minimumSizeHint(void)const " ([email protected]@@[email protected]@XZ) 
1>main.obj : error LNK2001: unresolved external symbol "protected: virtual void __cdecl QWidget::mouseDoubleClickEvent(class QMouseEvent *)" ([email protected]@@[email protected]@@Z) 
1>main.obj : error LNK2001: unresolved external symbol "protected: virtual void __cdecl QLabel::mouseMoveEvent(class QMouseEvent *)" ([email protected]@@[email protected]@@Z) 
1>main.obj : error LNK2001: unresolved external symbol "protected: virtual void __cdecl QLabel::mousePressEvent(class QMouseEvent *)" ([email protected]@@[email protected]@@Z) 
1>main.obj : error LNK2001: unresolved external symbol "protected: virtual void __cdecl QLabel::mouseReleaseEvent(class QMouseEvent *)" ([email protected]@@[email protected]@@Z) 
1>main.obj : error LNK2001: unresolved external symbol "protected: virtual void __cdecl QWidget::moveEvent(class QMoveEvent *)" ([email protected]@@[email protected]@@Z) 
1>main.obj : error LNK2001: unresolved external symbol "protected: virtual bool __cdecl QWidget::nativeEvent(class QByteArray const &,void *,long *)" ([email protected]@@[email protected]@[email protected]) 
1>main.obj : error LNK2001: unresolved external symbol "public: virtual class QPaintEngine * __cdecl QWidget::paintEngine(void)const " ([email protected]@@[email protected]@XZ) 
1>main.obj : error LNK2001: unresolved external symbol "protected: virtual void __cdecl QLabel::paintEvent(class QPaintEvent *)" ([email protected]@@[email protected]@@Z) 
1>main.obj : error LNK2001: unresolved external symbol "public: virtual int __cdecl QLabel::qt_metacall(enum QMetaObject::Call,int,void * *)" ([email protected]@@[email protected]@@[email protected]) 
1>main.obj : error LNK2001: unresolved external symbol "public: virtual void * __cdecl QLabel::qt_metacast(char const *)" ([email protected]@@[email protected]) 
1>main.obj : error LNK2001: unresolved external symbol "protected: virtual class QPaintDevice * __cdecl QWidget::redirected(class QPoint *)const " ([email protected]@@[email protected]@[email protected]@@Z) 
1>main.obj : error LNK2001: unresolved external symbol "protected: virtual void __cdecl QWidget::resizeEvent(class QResizeEvent *)" ([email protected]@@[email protected]@@Z) 
1>main.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl QWidget::setVisible(bool)" ([email protected]@@[email protected]) 
1>main.obj : error LNK2001: unresolved external symbol "protected: virtual class QPainter * __cdecl QWidget::sharedPainter(void)const " ([email protected]@@[email protected]@XZ) 
1>main.obj : error LNK2001: unresolved external symbol "protected: virtual void __cdecl QWidget::showEvent(class QShowEvent *)" ([email protected]@@[email protected]@@Z) 
1>main.obj : error LNK2001: unresolved external symbol "public: virtual class QSize __cdecl QLabel::sizeHint(void)const " ([email protected]@@[email protected]@XZ) 
1>main.obj : error LNK2001: unresolved external symbol "protected: virtual void __cdecl QWidget::tabletEvent(class QTabletEvent *)" ([email protected]@@[email protected]@@Z) 
1>main.obj : error LNK2001: unresolved external symbol "protected: virtual void __cdecl QWidget::wheelEvent(class QWheelEvent *)" ([email protected]@@[email protected]@@Z) 
+1

Вам необходимо связаться с библиотекой QT; то, что сообщает компоновщику символы, которые находятся в DLL. –

+0

Если нет ссылки на Qt, то что-то пошло не так с преобразованием проекта, которое мы не знаем. Вместо этого я попробую 'qmake -tp vc -r file.pro'. Существует несколько способов работы с проектом Qt -> VS, и вы можете попробовать найти некоторые из них: http://stackoverflow.com/questions/38248343/how-to-generate-64-bit-visual-studio-projects-from-qmake – AlexanderVX

ответ

-1

Я имел чтобы преобразовать проект еще раз в проект VC++ после того, как я отредактировал файл .pro, я этого не сделал. Программа работает сейчас.