C++ Qt:未定义对"_imp___ZN12QApplicationC1ERiPPci"的引用
C++ Qt: undefined reference to `_imp___ZN12QApplicationC1ERiPPci'
我试图提醒自己一些C++,同时也学习Qt。
我在Windows上工作。我已经安装了Qt(5.1.0)、MinGW(g++4.6.2)、Gnu Make(3.81)。
我正在尝试编译一个简单的Qt应用程序。最基本的情况是:
#include <QtWidgets>
#include <QtGui>
int main (int argc, char* argv[]) {
QApplication app(argc, argv);
QTextStream cout(stdout);
return EXIT_SUCCESS;
}
项目文件为:
TEMPLATE = app
TARGET = example1
INCLUDEPATH += .
# Input
SOURCES += fac1.cpp
QT += gui widgets core
当我运行时
qmake
它生成Makefile。
但后来有了make
,我得到了这个:
C:srcearly-examplesexample1>make
make -f Makefile.Release
make[1]: Entering directory `C:/src/early-examples/example1'
g++ -Wl,-s -Wl,-subsystem,console -mthreads -o releaseexample1.exe release/fac1.o -LC:QtQt5.1.0\5.1.0msvc2012_64lib -lQt5Widgets -lQt5Gui -lQt5Core -llibEGL -llibGLESv2 -lgdi32 -luser32
release/fac1.o:fac1.cpp:(.text.startup+0x2e): undefined reference to `_imp___ZN12QApplicationC1ERiPPci'
release/fac1.o:fac1.cpp:(.text.startup+0x37): undefined reference to `_imp___ZN12QApplicationD1Ev'
collect2: ld returned 1 exit status
make[1]: *** [releaseexample1.exe] Error 1
make[1]: Leaving directory `C:/src/early-examples/example1'
make: *** [release] Error 2
你能告诉我怎么了吗?
这里的问题是您的mingw构建似乎使用了Visual Studio 2012库。您需要链接到mingw编译的Qt。
将"greaterThan(QT_MAJOR_VERSION,4):QT+=widgets"添加到.pro文件
相关文章:
- 没有找到相关文章