Echows
Echows

Reputation: 317

How to use the QT library on Ubuntu

I have a piece of code that uses the QT library. More specifically, it contains the lines

#include <QApplication>
#include <QMainWindow>
#include <QtWidgets>

and some others that I believe are related to the Qt library. The code comes with some kind of a make file (I believe it's for some Microsoft editor) with the lines:

QT       += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

I'm trying to compile the code using gcc on my Ubuntu (16.10) system. I've tried giving the compiler option -lQtCore, but I get an error:

fatal error: QtWidgets: No such file or directory
fatal error: QMainWindow: No such file or directory

Which packages I need to install and which libraries I need to link with gcc to make it work?

Upvotes: 1

Views: 510

Answers (2)

Anon
Anon

Reputation: 2492

QT += core gui greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

That resembles a .pro file, and can be built using QtCreator.

Upvotes: 2

Michael
Michael

Reputation: 5335

This file is a Qt project file. Build the project with these commands:

qmake <Qt project file.pro>
make

Upvotes: 2

Related Questions