C ++ Qt: undefined reference to `_imp___ZN12QApplicationC1ERiPPci '

I'm trying to remind myself of C ++, and also learn about Qt.

I am working on windows. I installed Qt (5.1.0), MinGW (g ++ 4.6.2), Gnu Make (3.81).

I am trying to compile a simple Qt application. The simplest case:

#include <QtWidgets> #include <QtGui> int main (int argc, char* argv[]) { QApplication app(argc, argv); QTextStream cout(stdout); return EXIT_SUCCESS; } 

Project file:

 TEMPLATE = app TARGET = example1 INCLUDEPATH += . # Input SOURCES += fac1.cpp QT += gui widgets core 

When i started

 qmake 

he creates a makefile.

But then with make I get the following:

 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 

Can you tell me what is wrong?

+7
source share
3 answers

The problem is that you seem to be using Visual Studio 2012 libraries for your collections. Instead, you need to link to compiled Qt.

+9
source

Add the file "largeThan (QT_MAJOR_VERSION, 4): QT + = widgets" to your .pro

0
source

As Bevin pointed out, add the line below to the yout pro file. This will solve the problem. "moreThan (QT_MAJOR_VERSION, 4): QT + = widgets"

0
source

Source: https://habr.com/ru/post/951840/


All Articles