Question

I've started developing with qt from a few days. 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:

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

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

Thank You

Was it helpful?

Solution

I think your project file is wrong.

So you want a GUI application, but you remove the GUI module by

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. By default, QT contains both core and gui, so the following line will result in a minimal Qt project being built:

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

Try deleting the

QT       -= gui

line, since "Note that QT includes the core and gui modules by default". See source.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top