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?