There is a qt-hello.cpp file:

#include <QtWidgets> int main(int argc, char** argv) { QApplication app(argc, argv); QLabel lbl("Hello, World!"); lbl.show(); return app.exec(); } 

and the Hello.pro pro file:

 TEMPLATE = app QT += widgets SOURCES = qt-hello.cpp windows:TARGET = ../Hello 

after qmake -project -> qmake -> make error pops up:

 g++ -c -pipe -O2 -std=gnu++11 -Wall -W -D_REENTRANT -fPIC -DQT_DEPRECATED_WARNINGS -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -I. -I. -I/opt/qt510/include -I/opt/qt510/include/QtGui -I/opt/qt510/include/QtCore -I. -isystem /usr/include/libdrm -I/opt/qt510/mkspecs/linux-g++ -o qt-hello.o qt-hello.cpp qt-hello.cpp:1:21: fatal error: QtWidgets: No such file or directory compilation terminated. Makefile:656: recipe for target 'qt-hello.o' failed make: *** [qt-hello.o] Error 1 

Moreover, if I collect using cmake :

 cmake_minimum_required(VERSION 2.8.8) project(hello) set(CMAKE_AUTOMOC ON) add_definitions(-Wall -std=c++14) find_package(Qt5Widgets REQUIRED) set(SRC_MAIN qt-hello.cpp) add_executable(${PROJECT_NAME} ${SRC_MAIN}) qt5_use_modules(${PROJECT_NAME} Widgets) 

then everything is going to be normal. What is the problem? What did I do wrong in pro-file?

  • New Qt on Linux, yes? - Daniel Chizhevsky
  • @ DanielChizhevsky qt 5.10.1 - did you ask this? - Andrej Levkovitch 5:42 pm
  • @Andrej_Levkovitch, in the sense of the axle what is it worth? - Daniel Chizhevskiy
  • one
    @ DaniilChizhevsky I apologize, but I am not familiar with such terminology: I'm just starting to learn qt ... - Andrej Levkovitch
  • What operating system? =) - Daniel Chizhevsky

1 answer 1

In general, the problem arose from the fact that I did not understand the purpose of qmake -project ... It turned out (I did not know this yesterday) that this command automatically creates a .pro file in which, of course, widgets not included, and after the qmake command the utility creates a Makefile based on an automatically generated pro-file. In general, the qmake -project command is not needed here.