提问人:user39241 提问时间:11/14/2023 最后编辑:273Kuser39241 更新时间:11/14/2023 访问量:78
未定义对“__imp_qt_version_tag_6_6”的引用 [重复]
undefined reference to `__imp_qt_version_tag_6_6' [duplicate]
问:
msys2,安装 mingw-w64-qt6-base。我使用 make 构建。我通过pkg-config获取了路径。
mainwindow.h:
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QApplication>
#include <QtWidgets>
class MainWindow: public QMainWindow
{
Q_OBJECT
public:
MainWindow();
};
#endif
main.cpp:
#include <QApplication>
#include "mainwindow.h"
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
MainWindow w;
w.show();
return app.exec();
}
发生错误:
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: main.o:main.cpp:(.text+0x26): undefined reference to `__imp__ZN12QApplicationC1ERiPPci'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: main.o:main.cpp:(.text+0x3b): undefined reference to `__imp__ZN7QWidget4showEv'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: main.o:main.cpp:(.text+0x41): undefined reference to `__imp__ZN12QApplication4execEv'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: main.o:main.cpp:(.text+0x6c): undefined reference to `__imp__ZN11QMainWindowD2Ev'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: main.o:main.cpp:(.text+0x77): undefined reference to `__imp__ZN12QApplicationD1Ev'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: main.o:main.cpp:(.text+0xad): undefined reference to `__imp__ZN11QMainWindowD2Ev'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: main.o:main.cpp:(.text+0xb8): undefined reference to `__imp__ZN12QApplicationD1Ev'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: main.o:main.cpp:(.qtversion[qt_version_tag_6_6_used]+0x0): undefined reference to `__imp_qt_version_tag_6_6'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: main.o:main.cpp:(.rdata$.refptr._ZTV10MainWindow[.refptr._ZTV10MainWindow]+0x0): undefined reference to `vtable for MainWindow'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: mainwindow.o:mainwindow.cpp:(.text+0x15): undefined reference to `__imp__ZN11QMainWindowC2EP7QWidget6QFlagsIN2Qt10WindowTypeEE'
尝试删除 mainwindow.h 中的Q_OBJECT,并在 main.cpp 中添加 #include“main.moc”。不幸的是,我对Qt不够了解,无法自己解决问题......
答: 暂无答案
评论