我试图提醒自己一些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;
}
Run Code Online (Sandbox Code Playgroud)
项目文件是:
TEMPLATE = app
TARGET = example1
INCLUDEPATH += .
# Input
SOURCES += fac1.cpp
QT += gui widgets core
Run Code Online (Sandbox Code Playgroud)
我跑的时候
qmake
Run Code Online (Sandbox Code Playgroud)
它生成Makefile.
但随后make我得到了这个:
C:\src\early-examples\example1>make
make -f Makefile.Release
make[1]: Entering directory `C:/src/early-examples/example1'
g++ -Wl,-s -Wl,-subsystem,console -mthreads -o release\example1.exe release/fac1.o -LC:\Qt\Qt5.1.0\\5.1.0\msvc2012_64\lib -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]: *** [release\example1.exe] Error 1
make[1]: Leaving directory `C:/src/early-examples/example1'
make: *** [release] Error 2
Run Code Online (Sandbox Code Playgroud)
你能告诉我出了什么问题吗?
这里的问题是您似乎正在使用Visual Studio 2012库进行mingw构建.您需要链接到mingw编译的Qt.