我正在尝试编译一个Qt hello world程序。我在Windows 64位上使用QT5.2.0。这是我的密码
#include <QCoreApplication>
#include <QDebug>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
qDebug() << "Hello world";
return a.exec();
}当我运行应用程序时,我会得到以下运行时错误:
mingw32-make[1]: Entering directory 'C:/Users/test/qt_creator_projects/build-QtTest- TestLocal_PC-Debug'
g++ -c -pipe -fno-keep-inline-dllexport -g -frtti -Wall -Wextra -fexceptions -mthreads -DUNICODE -DQT_QML_DEBUG -DQT_DECLARATIVE_DEBUG -DQT_CORE_LIB -I..\QtTest -
I"D:\Qt\5.2.0\msvc2012_64\include" -I"D:\Qt\5.2.0\msvc2012_64\include\QtCore" -I"debug" -
I"." -I"D:\Qt\5.2.0\msvc2012_64\mkspecs\win32-g++" -o debug\main.o ..\QtTest\main.cpp
g++ -Wl,-subsystem,console -mthreads -o debug\QtTest.exe debug/main.o -
LD:\Qt\5.2.0\msvc2012_64\lib -lQt5Cored
debug/main.o: In function `main':
C:\Users\test\qt_creator_projects\build-QtTest-TestLocal_PC-
Debug/../QtTest/main.cpp:5: undefined reference to `_imp___ZN16QCoreApplicationC1ERiPPci'
C:\Users\test\qt_creator_projects\build-QtTest-TestLocal_PC- Debug/../QtTest/main.cpp:7: undefined reference to `_imp___ZN16QCoreApplication4execEv'
Makefile.Debug:77: recipe for target 'debug\QtTest.exe' failed
C:\Users\test\qt_creator_projects\build-QtTest-TestLocal_PC-
Debug/../QtTest/main.cpp:7: undefined reference to `_imp___ZN16QCoreApplicationD1Ev'
mingw32-make[1]: Leaving directory 'C:/Users/test/qt_creator_projects/build-QtTest- TestLocal_PC-Debug'
Makefile:34: recipe for target 'debug' failed
C:\Users\test\qt_creator_projects\build-QtTest-TestLocal_PC-Debug/../QtTest/main.cpp:7: undefined reference to `_imp___ZN16QCoreApplicationD1Ev'
collect2.exe: error: ld returned 1 exit status
mingw32-make[1]: *** [debug\QtTest.exe] Error 1
mingw32-make: *** [debug] Error 2
16:37:34: The process "D:\pen drive data\MinGW\bin\mingw32-make.exe" exited with code 2.
Error while building/deploying project QtTest (kit: TestLocal PC)
When executing step 'Make'.pro文件
QT += core
QT -= gui
TARGET = QtTest
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += main.cpp我想在MinGW .I am中使用Qt,目前在64位Visual 2012编译器中使用Qt。因为在5.2.0的下载中没有64位MinGW
有人能帮我解决这些参考错误吗?
发布于 2014-02-03 14:43:38
如果您没有VS2012版本的Qt,为什么要下载它呢?
下载与您所拥有的编译器完全匹配的版本。如果没有,请下载源代码并自己编译。
如果您想避免自编译的复杂性,那么VS2012 Express就完全适合使用Qt进行开发。它是与付费版本相同的编译器,如果使用Qt进行开发,那么您真的不关心快速版IDE可能有什么限制。效果很好。
另一种可能是使用Qt的混合构建。在安装过程中,可以启用MinGW 4.8.0工具链的安装。这为您提供了一个完整的开发环境,包括IDE、Qt头和二进制文件以及一个工具链。
https://stackoverflow.com/questions/21525905
复制相似问题