简体   繁体   English

与mingw32的Qt编译错误

[英]Qt compilation error with mingw32

I've started developing with qt from a few days. 几天后我开始用qt开发了。 I want to make a program that move the mouse cursor in certain positions that i decided, but when i compile even the simplest program, mingw32 print this errors: 我想制作一个程序,将鼠标光标移动到我决定的某些位置,但是当我编译最简单的程序时,mingw32打印出这个错误:

error: undefined reference to `_imp___ZN15QGuiApplicationC1ERiPPci'
error: undefined reference to `_imp___ZN7QCursorC1Ev'
error: undefined reference to `_imp___ZN7QCursor6setPosEii'
error: undefined reference to `_imp___ZN15QGuiApplicationD1Ev'
error: undefined reference to `_imp___ZN15QGuiApplicationD1Ev'
release/main.o: bad reloc address 0x13 in section `.eh_frame'
collect2.exe:-1: error: error: ld returned 1 exit status

This is my code: 这是我的代码:

#include <QtGui/QGuiApplication>
#include <QtGui/QCursor>

int main(int argc, char *argv[])
{
    QGuiApplication a(argc, argv);
    QCursor *cur = new QCursor;
    cur->setPos(50,50);
    return 0;

    return a.exec();
}

.pro file .pro文件

QT       += core

QT       -= gui

TARGET = untitled
CONFIG   += console
CONFIG   -= app_bundle

TEMPLATE = app


SOURCES += main.cpp

What I wrong??? 我错了什么??? How I can fix it?? 我怎么能解决它?

I installed Qt 5.1 with mingw32 on Win8 Pro x64 我在Win8 Pro x64上安装了Qt 5.1和mingw32

Thank You 谢谢

I think your project file is wrong. 我认为你的项目文件是错误的。

So you want a GUI application, but you remove the GUI module by 所以你想要一个GUI应用程序,但你删除了GUI模块

QT       -= gui

Have you tried creating this application with the project start wizard? 您是否尝试使用项目启动向导创建此应用程序? I think you may have selected the wrong type of application. 我想你可能选择了错误的应用程序类型。

EDIT 编辑

If you want to build a project without the gui module, you need to exclude it with the "-=" operator. 如果要在没有gui模块的情况下构建项目,则需要使用“ - =”运算符将其排除。 By default, QT contains both core and gui, so the following line will result in a minimal Qt project being built: 默认情况下,QT包含core和gui,因此以下行将导致构建一个最小的Qt项目:

QT -= gui # Only the core module is used.

So, you only have the core module. 所以,你只有核心模块。 Source: http://qt-project.org/doc/qt-4.8/qmake-project-files.html 资料来源: http//qt-project.org/doc/qt-4.8/qmake-project-files.html

Try deleting the 尝试删除

QT       -= gui

line, since "Note that QT includes the core and gui modules by default". line,因为“请注意,QT默认包含core和gui模块”。 See source. 见源。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM