[英]Error when compiling QtGstreamer using Cmake and Mingw32 Compiler comes with QT 5.12.3
[英]Qt compilation error with mingw32
幾天后我開始用qt開發了。 我想制作一個程序,將鼠標光標移動到我決定的某些位置,但是當我編譯最簡單的程序時,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
這是我的代碼:
#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文件
QT += core
QT -= gui
TARGET = untitled
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += main.cpp
我錯了什么??? 我怎么能解決它?
我在Win8 Pro x64上安裝了Qt 5.1和mingw32
謝謝
我認為你的項目文件是錯誤的。
所以你想要一個GUI應用程序,但你刪除了GUI模塊
QT -= gui
您是否嘗試使用項目啟動向導創建此應用程序? 我想你可能選擇了錯誤的應用程序類型。
編輯
如果要在沒有gui模塊的情況下構建項目,則需要使用“ - =”運算符將其排除。 默認情況下,QT包含core和gui,因此以下行將導致構建一個最小的Qt項目:
QT -= gui # Only the core module is used.
所以,你只有核心模塊。 資料來源: http : //qt-project.org/doc/qt-4.8/qmake-project-files.html
嘗試刪除
QT -= gui
line,因為“請注意,QT默認包含core和gui模塊”。 見源。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.